From c95d9e7288722932b5002c5acc17a3a5a530fbf0 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Mon, 30 Sep 2024 09:31:45 +0300 Subject: [PATCH 1/7] Fix "docstring wider than 80 characters" errors --- purescript-indent.el | 3 ++- purescript-mode.el | 4 +++- purescript-move-nested.el | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/purescript-indent.el b/purescript-indent.el index eec177f..700940b 100644 --- a/purescript-indent.el +++ b/purescript-indent.el @@ -432,7 +432,8 @@ Returns the location of the start of the comment, nil otherwise." (purescript-indent-skip-blanks-and-newlines-forward end)))) (defun purescript-indent-next-symbol-safe (end) - "Puts point to the next following symbol, or to end if there are no more symbols in the sexp." + "Puts point to the next following symbol, or to end if there are no more +symbols in the sexp." (condition-case errlist (purescript-indent-next-symbol end) (error (goto-char end)))) diff --git a/purescript-mode.el b/purescript-mode.el index dc20508..78d1c15 100644 --- a/purescript-mode.el +++ b/purescript-mode.el @@ -445,7 +445,9 @@ is asked to show extra info for the items matching QUERY.." :safe 'integerp) (defun purescript-mode-suggest-indent-choice () - "Ran when the user tries to indent in the buffer but no indentation mode has been selected. + "Ran when the user tries to indent in the buffer but no indentation mode +has been selected. + Brings up the documentation for purescript-mode-hook." (describe-variable 'purescript-mode-hook)) diff --git a/purescript-move-nested.el b/purescript-move-nested.el index 43b948e..dc5e26a 100644 --- a/purescript-move-nested.el +++ b/purescript-move-nested.el @@ -34,7 +34,8 @@ ;;;###autoload (defun purescript-move-nested (cols) - "Shift the nested off-side-rule block adjacent to point by COLS columns to the right. + "Shift the nested off-side-rule block adjacent to point by COLS columns +to the right. In Transient Mark mode, if the mark is active, operate on the contents of the region instead. From aa052e3f4d46669c535ff702676c122c25c6b419 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Mon, 30 Sep 2024 09:50:26 +0300 Subject: [PATCH 2/7] Escape single quotes in docstrings Fixes warnings: purescript-font-lock.el:448:2: Error: docstring has wrong usage of unescaped single quotes (use \=' or different quoting such as `...') purescript-indent.el:1321:2: Error: docstring has wrong usage of unescaped single quotes (use \=' or different quoting such as `...') purescript-mode.el:88:2: Error: docstring has wrong usage of unescaped single quotes (use \=' or different quoting such as `...') --- purescript-font-lock.el | 10 +++++----- purescript-indent.el | 2 +- purescript-mode.el | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/purescript-font-lock.el b/purescript-font-lock.el index e0e3556..812f9b1 100644 --- a/purescript-font-lock.el +++ b/purescript-font-lock.el @@ -448,7 +448,7 @@ that should be commented under LaTeX-style literate scripts." (defun turn-on-purescript-font-lock () "Turns on font locking in current buffer for PureScript 1.4 scripts. -Changes the current buffer's `font-lock-defaults', and adds the +Changes the current buffer\\='s `font-lock-defaults', and adds the following variables: `purescript-keyword-face' for reserved keywords and syntax, @@ -470,7 +470,7 @@ Use the variable `font-lock-maximum-decoration' to choose non-default levels of fontification. For example, adding this to .emacs: - (setq font-lock-maximum-decoration '((purescript-mode . 2) (t . 0))) + (setq font-lock-maximum-decoration \\='((purescript-mode . 2) (t . 0))) uses level two fontification for `purescript-mode' and default level for all other modes. See documentation on this variable for further @@ -480,9 +480,9 @@ To alter an attribute of a face, add a hook. For example, to change the foreground colour of comments to brown, add the following line to .emacs: - (add-hook 'purescript-font-lock-hook + (add-hook \\='purescript-font-lock-hook (lambda () - (set-face-foreground 'purescript-comment-face \"brown\"))) + (set-face-foreground \\='purescript-comment-face \"brown\"))) Note that the colours available vary from system to system. To see what colours are available on your system, call @@ -490,7 +490,7 @@ what colours are available on your system, call To turn font locking on for all PureScript buffers, add this to .emacs: - (add-hook 'purescript-mode-hook 'turn-on-purescript-font-lock) + (add-hook \\='purescript-mode-hook \\='turn-on-purescript-font-lock) To turn font locking on for the current buffer, call `turn-on-purescript-font-lock'. To turn font locking off in the current diff --git a/purescript-indent.el b/purescript-indent.el index 700940b..95c169e 100644 --- a/purescript-indent.el +++ b/purescript-indent.el @@ -1321,7 +1321,7 @@ of the regions to move." (defun purescript-indent-align-def (p-arg type) "Align guards or rpurs within the current definition before point. If P-ARG is t align all defs up to the mark. -TYPE is either 'guard or 'rpurs." +TYPE is either \\='guard or \\='rpurs." (save-excursion (let (start-block end-block (maxcol (if (eq type 'rpurs) purescript-indent-rpurs-align-column 0)) diff --git a/purescript-mode.el b/purescript-mode.el index 78d1c15..068e494 100644 --- a/purescript-mode.el +++ b/purescript-mode.el @@ -87,7 +87,7 @@ When MESSAGE is non-nil, display a message with the version." ;;;###autoload (defun purescript-customize () "Browse the purescript customize sub-tree. -This calls 'customize-browse' with purescript as argument and makes +This calls `customize-browse' with purescript as argument and makes sure all purescript customize definitions have been loaded." (interactive) ;; make sure all modules with (defcustom ...)s are loaded From a01fc3c2a550873b4e2d4ff13e6922ddb2af9f4f Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Mon, 30 Sep 2024 10:05:27 +0300 Subject: [PATCH 3/7] purescript-mode.el: don't start variable used with an underscore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's reserved for unused variables. Fixes a warning: purescript-mode.el:63:11: Error: variable ‘_version’ not left unused --- purescript-mode.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/purescript-mode.el b/purescript-mode.el index 068e494..c2be498 100644 --- a/purescript-mode.el +++ b/purescript-mode.el @@ -60,13 +60,13 @@ When MESSAGE is non-nil, display a message with the version." (interactive "P") (let* ((purescript-mode-dir (ignore-errors (file-name-directory (or (locate-library "purescript-mode") "")))) - (_version (format "purescript-mode version %s (%s @ %s)" + (version (format "purescript-mode version %s (%s @ %s)" purescript-version purescript-git-version purescript-mode-dir))) (if here - (insert _version) - (message "%s" _version)))) + (insert version) + (message "%s" version)))) ;;;###autoload (defun purescript-mode-view-news () From d98ad00c38b8843578ccd28e65ce57383a0fdd90 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Mon, 30 Sep 2024 09:52:32 +0300 Subject: [PATCH 4/7] Remove/rename unused lexical arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: purescript-indent.el:437:19: Error: Unused lexical variable ‘errlist’ purescript-indent.el:1295:34: Error: Unused lexical argument ‘start’ purescript-mode.el:416:44: Error: Unused lexical argument ‘info’ --- purescript-indent.el | 8 ++++---- purescript-mode.el | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/purescript-indent.el b/purescript-indent.el index 95c169e..5404fb6 100644 --- a/purescript-indent.el +++ b/purescript-indent.el @@ -434,7 +434,7 @@ Returns the location of the start of the comment, nil otherwise." (defun purescript-indent-next-symbol-safe (end) "Puts point to the next following symbol, or to end if there are no more symbols in the sexp." - (condition-case errlist (purescript-indent-next-symbol end) + (condition-case nil (purescript-indent-next-symbol end) (error (goto-char end)))) (defun purescript-indent-separate-valdef (start end) @@ -1292,7 +1292,7 @@ We stay in the cycle as long as the TAB key is pressed." (if marker (goto-char (marker-position marker))))))) -(defun purescript-indent-region (start end) +(defun purescript-indent-region (_start _end) (error "Auto-reindentation of a region is not supported")) ;;; alignment functions @@ -1430,9 +1430,9 @@ TYPE is either \\='guard or \\='rpurs." (if regstack (purescript-indent-shift-columns maxcol regstack))))))) -(defun purescript-indent-align-guards-and-rpurs (start end) +(defun purescript-indent-align-guards-and-rpurs (_start _end) "Align the guards and rpurs of functions in the region, which must be active." - ;; The `start' and `end' args are dummys right now: they're just there so + ;; The `_start' and `_end' args are dummys right now: they're just there so ;; we can use the "r" interactive spec which properly signals an error. (interactive "*r") (purescript-indent-align-def t 'guard) diff --git a/purescript-mode.el b/purescript-mode.el index c2be498..5609810 100644 --- a/purescript-mode.el +++ b/purescript-mode.el @@ -413,7 +413,7 @@ see documentation for that variable for more details." ;;;###autoload(add-to-list 'auto-mode-alist '("\\.purs\\'" . purescript-mode)) -(defun purescript-pursuit (query &optional info) +(defun purescript-pursuit (query &optional _info) "Do a Pursuit search for QUERY. When `purescript-pursuit-command' is non-nil, this command runs that. Otherwise, it opens a Pursuit search result in the browser. From c8dad403038ee7b819c0aec6d8b65835d92cbfa8 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Mon, 30 Sep 2024 10:13:20 +0300 Subject: [PATCH 5/7] Remove unused let-binding for `point` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: purescript-navigate-imports.el:101:12: Error: Unused lexical variable ‘point’ purescript-simple-indent.el:146:10: Error: Unused lexical variable ‘point’ --- purescript-navigate-imports.el | 7 +++---- purescript-simple-indent.el | 25 ++++++++++++------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/purescript-navigate-imports.el b/purescript-navigate-imports.el index 037f597..0c4c806 100644 --- a/purescript-navigate-imports.el +++ b/purescript-navigate-imports.el @@ -98,10 +98,9 @@ (purescript-navigate-imports-after-imports-p) ;; This one just speeds it up. (purescript-navigate-imports-line))) (forward-line)) - (let ((point (point))) - (if (purescript-navigate-imports-line) - (point) - nil)))) + (if (purescript-navigate-imports-line) + (point) + nil))) (defun purescript-navigate-imports-line () "Try to match the current line as a regexp." diff --git a/purescript-simple-indent.el b/purescript-simple-indent.el index 1b5d36c..2690f0c 100644 --- a/purescript-simple-indent.el +++ b/purescript-simple-indent.el @@ -143,19 +143,18 @@ column, `tab-to-tab-stop' is done instead." (defun purescript-simple-indent-newline-same-col () "Make a newline and go to the same column as the current line." (interactive) - (let ((point (point))) - (let ((start-end - (save-excursion - (let* ((start (line-beginning-position)) - (end (progn (goto-char start) - (search-forward-regexp - "[^ ]" (line-end-position) t 1)))) - (when end (cons start (1- end))))))) - (if start-end - (progn (newline) - (insert (buffer-substring-no-properties - (car start-end) (cdr start-end)))) - (newline))))) + (let ((start-end + (save-excursion + (let* ((start (line-beginning-position)) + (end (progn (goto-char start) + (search-forward-regexp + "[^ ]" (line-end-position) t 1)))) + (when end (cons start (1- end))))))) + (if start-end + (progn (newline) + (insert (buffer-substring-no-properties + (car start-end) (cdr start-end)))) + (newline)))) (defun purescript-simple-indent-newline-indent () "Make a newline on the current column and indent on step." From 7eacda36f9ee310e2115a7753cbca5e0e7726698 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Mon, 30 Sep 2024 10:14:49 +0300 Subject: [PATCH 6/7] purescript-sort-imports.el: make sure (interactive) is after docstring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: purescript-sort-imports.el:41:4: Error: Doc string after ‘interactive’ --- purescript-sort-imports.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/purescript-sort-imports.el b/purescript-sort-imports.el index d46cecb..a1374ca 100644 --- a/purescript-sort-imports.el +++ b/purescript-sort-imports.el @@ -38,12 +38,12 @@ ;;;###autoload (defun purescript-sort-imports () - (interactive) "Sort the import list at point. It sorts the current group i.e. an import list separated by blank lines on either side. If the region is active, it will restrict the imports to sort within that region." + (interactive) (when (purescript-sort-imports-at-import) (let* ((points (purescript-sort-imports-decl-points)) (current-string (buffer-substring-no-properties (car points) From 9a9f55043872b9621286c5e2752f7f09fb07450e Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Mon, 30 Sep 2024 09:39:30 +0300 Subject: [PATCH 7/7] Enable lexical binding in all .el files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream Emacs has made lack of the directive a warning. So enable it explicitly everywhere. It provides various benefits such as better introspection by the compiler into the code and optimizations. Fixes a bunch of warnings: Error: file has no ‘lexical-binding’ directive on its first line --- purescript-align-imports.el | 2 +- purescript-collapse.el | 2 +- purescript-decl-scan.el | 2 +- purescript-font-lock.el | 2 +- purescript-indent.el | 2 +- purescript-indentation.el | 2 +- purescript-mode.el | 2 +- purescript-move-nested.el | 2 +- purescript-navigate-imports.el | 2 +- purescript-presentation-mode.el | 2 +- purescript-show.el | 2 +- purescript-simple-indent.el | 2 +- purescript-sort-imports.el | 2 +- purescript-str.el | 2 +- purescript-string.el | 1 + purescript-unicode-input-method.el | 2 +- purescript-utils.el | 2 +- purescript-yas.el | 2 +- tests/haskell-sort-imports-tests.el | 2 +- 19 files changed, 19 insertions(+), 18 deletions(-) diff --git a/purescript-align-imports.el b/purescript-align-imports.el index 56eabe2..5c36611 100644 --- a/purescript-align-imports.el +++ b/purescript-align-imports.el @@ -1,4 +1,4 @@ -;;; purescript-align-imports.el --- Align the import lines in a PureScript file +;;; purescript-align-imports.el --- Align the import lines in a PureScript file -*- lexical-binding: t -*- ;; Copyright (C) 2010 Chris Done diff --git a/purescript-collapse.el b/purescript-collapse.el index d6ddb92..e090644 100644 --- a/purescript-collapse.el +++ b/purescript-collapse.el @@ -1,4 +1,4 @@ -;;; purescript-collapse.el --- Collapse expressions +;;; purescript-collapse.el --- Collapse expressions -*- lexical-binding: t -*- ;; Copyright (c) 2014 Chris Done. All rights reserved. diff --git a/purescript-decl-scan.el b/purescript-decl-scan.el index f588cba..b3b61ed 100644 --- a/purescript-decl-scan.el +++ b/purescript-decl-scan.el @@ -1,4 +1,4 @@ -;;; purescript-decl-scan.el --- Declaration scanning module for PureScript Mode +;;; purescript-decl-scan.el --- Declaration scanning module for PureScript Mode -*- lexical-binding: t -*- ;; Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. ;; Copyright (C) 1997-1998 Graeme E Moss diff --git a/purescript-font-lock.el b/purescript-font-lock.el index 812f9b1..85d4b7d 100644 --- a/purescript-font-lock.el +++ b/purescript-font-lock.el @@ -1,4 +1,4 @@ -;;; purescript-font-lock.el --- Font locking module for PureScript Mode +;;; purescript-font-lock.el --- Font locking module for PureScript Mode -*- lexical-binding: t -*- ;; Copyright 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. ;; Copyright 1997-1998 Graeme E Moss, and Tommy Thorn diff --git a/purescript-indent.el b/purescript-indent.el index 5404fb6..05a1c34 100644 --- a/purescript-indent.el +++ b/purescript-indent.el @@ -1,4 +1,4 @@ -;;; purescript-indent.el --- "semi-intelligent" indentation module for PureScript Mode +;;; purescript-indent.el --- "semi-intelligent" indentation module for PureScript Mode -*- lexical-binding: t -*- ;; Copyright 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc. ;; Copyright 1997-1998 Guy Lapalme diff --git a/purescript-indentation.el b/purescript-indentation.el index 5f8cea3..52c849b 100644 --- a/purescript-indentation.el +++ b/purescript-indentation.el @@ -1,4 +1,4 @@ -;;; purescript-indentation.el -- indentation module for PureScript Mode -*- lexical-binding: t -*- +;;; purescript-indentation.el -- indentation module for PureScript Mode -*- lexical-binding: t -*- -*- lexical-binding: t -*- ;; Copyright (C) 2009 Kristof Bastiaensen diff --git a/purescript-mode.el b/purescript-mode.el index 5609810..205c67e 100644 --- a/purescript-mode.el +++ b/purescript-mode.el @@ -1,4 +1,4 @@ -;;; purescript-mode.el --- A PureScript editing mode -*- coding: utf-8 -*- +;;; purescript-mode.el --- A PureScript editing mode -*- coding: utf-8 lexical-binding: t -*- ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc ;; Copyright (C) 1992, 1997-1998 Simon Marlow, Graeme E Moss, and Tommy Thorn diff --git a/purescript-move-nested.el b/purescript-move-nested.el index dc5e26a..98a2f6d 100644 --- a/purescript-move-nested.el +++ b/purescript-move-nested.el @@ -1,4 +1,4 @@ -;;; purescript-move-nested.el --- Change the column of text nested below a line +;;; purescript-move-nested.el --- Change the column of text nested below a line -*- lexical-binding: t -*- ;; Copyright (C) 2010 Chris Done diff --git a/purescript-navigate-imports.el b/purescript-navigate-imports.el index 0c4c806..749f8ad 100644 --- a/purescript-navigate-imports.el +++ b/purescript-navigate-imports.el @@ -1,4 +1,4 @@ -;;; purescript-navigate-imports.el --- A function for cycling through PureScript import lists +;;; purescript-navigate-imports.el --- A function for cycling through PureScript import lists -*- lexical-binding: t -*- ;; Copyright (C) 2010 Chris Done diff --git a/purescript-presentation-mode.el b/purescript-presentation-mode.el index 54c3c33..1a8fa9b 100644 --- a/purescript-presentation-mode.el +++ b/purescript-presentation-mode.el @@ -1,4 +1,4 @@ -;;; purescript-presentation-mode.el --- Presenting PureScript things +;;; purescript-presentation-mode.el --- Presenting PureScript things -*- lexical-binding: t -*- ;; Copyright (C) 2013 Chris Done diff --git a/purescript-show.el b/purescript-show.el index 63a6d97..f380329 100644 --- a/purescript-show.el +++ b/purescript-show.el @@ -1,4 +1,4 @@ -;;; purescript-show.el --- A pretty printer for PureScript Show values +;;; purescript-show.el --- A pretty printer for PureScript Show values -*- lexical-binding: t -*- ;; Copyright (C) 2011 Chris Done diff --git a/purescript-simple-indent.el b/purescript-simple-indent.el index 2690f0c..5c0cf5e 100644 --- a/purescript-simple-indent.el +++ b/purescript-simple-indent.el @@ -1,4 +1,4 @@ -;;; purescript-simple-indent.el --- Simple indentation module for PureScript Mode +;;; purescript-simple-indent.el --- Simple indentation module for PureScript Mode -*- lexical-binding: t -*- ;; Copyright (C) 1998 Heribert Schuetz, Graeme E Moss diff --git a/purescript-sort-imports.el b/purescript-sort-imports.el index a1374ca..c635ada 100644 --- a/purescript-sort-imports.el +++ b/purescript-sort-imports.el @@ -1,4 +1,4 @@ -;;; purescript-sort-imports.el --- Sort the list of PureScript imports at the point alphabetically +;;; purescript-sort-imports.el --- Sort the list of PureScript imports at the point alphabetically -*- lexical-binding: t -*- ;; Copyright (C) 2010 Chris Done diff --git a/purescript-str.el b/purescript-str.el index 6e960d0..8f6c3a3 100644 --- a/purescript-str.el +++ b/purescript-str.el @@ -1,4 +1,4 @@ -;;; purescript-str.el --- PureScript related string utilities +;;; purescript-str.el --- PureScript related string utilities -*- lexical-binding: t -*- ;; Copyright (C) 2013 Herbert Valerio Riedel diff --git a/purescript-string.el b/purescript-string.el index b8a74af..23af498 100644 --- a/purescript-string.el +++ b/purescript-string.el @@ -1,3 +1,4 @@ +;;; purescript-string.el --- string manipulation utilties -*- lexical-binding: t -*- ;;;###autoload (defun purescript-trim (string) (replace-regexp-in-string diff --git a/purescript-unicode-input-method.el b/purescript-unicode-input-method.el index 15cc7a0..da5f521 100644 --- a/purescript-unicode-input-method.el +++ b/purescript-unicode-input-method.el @@ -1,4 +1,4 @@ -;;; purescript-unicode-input-method.el --- PureScript Unicode helper functions -*- coding: utf-8 -*- +;;; purescript-unicode-input-method.el --- PureScript Unicode helper functions -*- coding: utf-8 lexical-binding: t -*- ;; Copyright (C) 2010-2011 Roel van Dijk diff --git a/purescript-utils.el b/purescript-utils.el index 294dcfb..5651e87 100644 --- a/purescript-utils.el +++ b/purescript-utils.el @@ -1,4 +1,4 @@ -;;; purescript-utils.el --- General utility functions used by purescript-mode modules +;;; purescript-utils.el --- General utility functions used by purescript-mode modules -*- lexical-binding: t -*- ;; Copyright (C) 2013 Herbert Valerio Riedel diff --git a/purescript-yas.el b/purescript-yas.el index 08339ef..a531e73 100644 --- a/purescript-yas.el +++ b/purescript-yas.el @@ -1,4 +1,4 @@ -;;; purescript-yas.el --- Customization support for Luke Hoersten's yasnippets +;;; purescript-yas.el --- Customization support for Luke Hoersten's yasnippets -*- lexical-binding: t -*- ;; Copyright (C) 2013 John Wiegley, Luke Hoersten diff --git a/tests/haskell-sort-imports-tests.el b/tests/haskell-sort-imports-tests.el index 656bdd0..7670fb2 100644 --- a/tests/haskell-sort-imports-tests.el +++ b/tests/haskell-sort-imports-tests.el @@ -1,4 +1,4 @@ -;;; purescript-sort-imports-tests.el --- Unit tests for purescript-sort-imports +;;; purescript-sort-imports-tests.el --- Unit tests for purescript-sort-imports -*- lexical-binding: t -*- ;; Copyright (c) 2014 Chris Done. All rights reserved.