From 518178ba6c6789379e6b9fe45e304ce62bfd2fc2 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Sun, 25 May 2025 22:06:18 +0300 Subject: [PATCH 1/3] Replace purescript-trim with string-trim This is a common helper Emacs had for a while, no need to keep our own function. --- purescript-indent.el | 7 +++++-- purescript-mode.el | 2 +- purescript-string.el | 8 -------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/purescript-indent.el b/purescript-indent.el index c21b265..31cf2c4 100644 --- a/purescript-indent.el +++ b/purescript-indent.el @@ -91,6 +91,9 @@ (require 'purescript-vars) (require 'purescript-string) (require 'cl-lib) +(eval-when-compile + (when (< emacs-major-version 28) + (require 'subr-x))) (defgroup purescript-indent nil "PureScript indentation." @@ -655,8 +658,8 @@ symbols in the sexp." (string-match "where[ \t]*" purescript-indent-current-line-first-ident)) (diff-first ; not a function def with the same name (or (null valname-string) - (not (string= (purescript-trim valname-string) - (purescript-trim purescript-indent-current-line-first-ident))))) + (not (string= (string-trim valname-string) + (string-trim purescript-indent-current-line-first-ident))))) ;; (is-type-def ;; (and rpurs-sign (eq (char-after rpurs-sign) ?\:))) diff --git a/purescript-mode.el b/purescript-mode.el index f646835..0bb61bf 100644 --- a/purescript-mode.el +++ b/purescript-mode.el @@ -439,7 +439,7 @@ Brings up the documentation for purescript-mode-hook." (message "%s" (concat (car lines) (if (and (cdr lines) (stringp (cadr lines))) - (format " [ %s .. ]" (purescript-string-take (purescript-trim (cadr lines)) 10)) + (format " [ %s .. ]" (purescript-string-take (string-trim (cadr lines)) 10)) "")))))) (defun purescript-current-line-string () diff --git a/purescript-string.el b/purescript-string.el index 23af498..9270385 100644 --- a/purescript-string.el +++ b/purescript-string.el @@ -1,12 +1,4 @@ ;;; purescript-string.el --- string manipulation utilties -*- lexical-binding: t -*- -;;;###autoload -(defun purescript-trim (string) - (replace-regexp-in-string - "^[ \t\n]+" "" - (replace-regexp-in-string - "[ \t\n]+$" "" - string))) - ;;;###autoload (defun purescript-string-take (string n) "Take n chars from string." From 8144869f4802b1c5ceff0f3e3e157b63d94ab980 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Sun, 25 May 2025 22:07:43 +0300 Subject: [PATCH 2/3] Un-globalize purescript-string-take It's a small utility function used in one place, and is unlikely used by anyone else. There's no need to keep it autoloaded and in a separate file. --- purescript-mode.el | 6 ++++++ purescript-string.el | 7 ------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/purescript-mode.el b/purescript-mode.el index 0bb61bf..c2f4455 100644 --- a/purescript-mode.el +++ b/purescript-mode.el @@ -432,6 +432,12 @@ Brings up the documentation for purescript-mode-hook." (goto-char (+ (line-beginning-position) col)))) +(defun purescript-string-take (string n) + "Take n chars from string." + (substring string + 0 + (min (length string) n))) + (defun purescript-mode-message-line (str) "Message only one line, multiple lines just disturbs the programmer." (let ((lines (split-string str "\n" t))) diff --git a/purescript-string.el b/purescript-string.el index 9270385..d8f4652 100644 --- a/purescript-string.el +++ b/purescript-string.el @@ -1,11 +1,4 @@ ;;; purescript-string.el --- string manipulation utilties -*- lexical-binding: t -*- -;;;###autoload -(defun purescript-string-take (string n) - "Take n chars from string." - (substring string - 0 - (min (length string) n))) - ;;;###autoload (defun purescript-is-prefix-of (x y) "Is x string a prefix of y string?" From baa0714c5be64deaee763e07946ee656dbeef330 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Sun, 25 May 2025 22:10:54 +0300 Subject: [PATCH 3/3] Remove purescript-string.el It has just one utility function which is unlikely being used by anyone. Remove it. --- Makefile | 1 - purescript-indent.el | 1 - purescript-mode.el | 1 - purescript-string.el | 9 --------- 4 files changed, 12 deletions(-) delete mode 100644 purescript-string.el diff --git a/Makefile b/Makefile index efb5994..d86ccf9 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,6 @@ ELFILES = \ purescript-simple-indent.el \ purescript-sort-imports.el \ purescript-str.el \ - purescript-string.el \ purescript-unicode-input-method.el \ purescript-utils.el \ purescript-decl-scan.el \ diff --git a/purescript-indent.el b/purescript-indent.el index 31cf2c4..fe0b490 100644 --- a/purescript-indent.el +++ b/purescript-indent.el @@ -89,7 +89,6 @@ ;;; Code: (require 'purescript-vars) -(require 'purescript-string) (require 'cl-lib) (eval-when-compile (when (< emacs-major-version 28) diff --git a/purescript-mode.el b/purescript-mode.el index c2f4455..a181651 100644 --- a/purescript-mode.el +++ b/purescript-mode.el @@ -37,7 +37,6 @@ (require 'purescript-vars) (require 'purescript-align-imports) (require 'purescript-sort-imports) -(require 'purescript-string) (require 'purescript-font-lock) (require 'cl-lib) (cl-eval-when 'compile (require 'find-file)) diff --git a/purescript-string.el b/purescript-string.el deleted file mode 100644 index d8f4652..0000000 --- a/purescript-string.el +++ /dev/null @@ -1,9 +0,0 @@ -;;; purescript-string.el --- string manipulation utilties -*- lexical-binding: t -*- -;;;###autoload -(defun purescript-is-prefix-of (x y) - "Is x string a prefix of y string?" - (string= x (substring y 0 (min (length y) (length x))))) - -(defun purescript-string ()) - -(provide 'purescript-string)