[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/hyperbole fc7e33b5e5 11/16: * hui-select.el: Fix a few wa
From: |
Stefan Monnier |
Subject: |
[elpa] scratch/hyperbole fc7e33b5e5 11/16: * hui-select.el: Fix a few warnings and improve some docstrings |
Date: |
Mon, 19 Jun 2023 22:36:45 -0400 (EDT) |
branch: scratch/hyperbole
commit fc7e33b5e53c2d059c6d302351f8cb3c5657c5a8
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
* hui-select.el: Fix a few warnings and improve some docstrings
(hui-select-initialize): Use `dolist`; let-bind
vars rather than just `setq`ing them; use closures.
(hui-select-goto-matching-tag): Fix markup.
(hui-select-indent-non-end-regexp-alist)
(hui-select-indent-end-regexp-alist): Use conventional markup for metavars.
---
hui-select.el | 62 ++++++++++++++++++++++++++++++-----------------------------
1 file changed, 32 insertions(+), 30 deletions(-)
diff --git a/hui-select.el b/hui-select.el
index c807d8ced7..9633c61e21 100644
--- a/hui-select.el
+++ b/hui-select.el
@@ -169,7 +169,7 @@ Use for language major modes."
(Info-mode "[^ \t\n]")
(outline-mode "[^*]")
(text-mode "[^ \t\n*]"))
- "List of (major-mode . non-terminator-line-regexp) elements.
+ "List of (MAJOR-MODE . NON-TERMINATOR-LINE-REGEXP) elements.
Used to avoid early dropoff when marking indented code.")
(defvar hui-select-indent-end-regexp-alist
@@ -185,7 +185,7 @@ Used to avoid early dropoff when marking indented code.")
(indented-text-mode "[ \t]*$")
(Info-mode "[ \t]*$")
(text-mode "[ \t]*$"))
- "List of (major-mode . terminator-line-regexp) elements.
+ "List of (MAJOR-MODE . TERMINATOR-LINE-REGEXP) elements.
Used to include a final line when marking indented code.")
(defcustom hui-select-char-p nil
@@ -366,33 +366,35 @@ Also, add language-specific syntax setups to aid in thing
selection."
;;
;; Make tag begin and end delimiters act like grouping characters,
;; for easy syntactical selection of tags.
- (let (hook-sym mode-str)
- (mapc (lambda (mode)
- (setq mode-str (symbol-name mode)
- hook-sym (intern (concat mode-str "-hook"))
- syntax-table-sym (intern (concat mode-str "-syntax-table"))
- keymap-sym (intern (concat mode-str "-map")))
- (var:add-and-run-hook hook-sym
- `(lambda ()
- (let ((syntax-table (symbol-value
',syntax-table-sym))
- (keymap (symbol-value
',keymap-sym)))
- (modify-syntax-entry ?\< "(>"
syntax-table)
- (modify-syntax-entry ?\> ")<"
syntax-table)
- (modify-syntax-entry ?\{ "(}"
syntax-table)
- (modify-syntax-entry ?\} "){"
syntax-table)
- (modify-syntax-entry ?\" "\""
syntax-table)
- (modify-syntax-entry ?= "."
syntax-table)
- (modify-syntax-entry ?. "_"
syntax-table)
- (setq sentence-end "\\([^
\t\n\r>]<\\|>\\(<[^>]*>\\)*\\|[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)\\)[ \t\n]*")
- (define-key keymap "\C-c."
'hui-select-goto-matching-tag))))
- (unless (eq mode 'web-mode)
- (var:add-and-run-hook
- hook-sym (lambda ()
- (make-local-variable 'comment-start)
- (make-local-variable 'comment-end)
- (setq comment-start "<!--" comment-end "-->")
- (make-local-variable 'sentence-end)))))
- hui-select-markup-modes)))
+ (dolist (mode hui-select-markup-modes)
+ (let* ((mode-str (symbol-name mode))
+ (hook-sym (intern (concat mode-str "-hook")))
+ (syntax-table-sym (intern (concat mode-str "-syntax-table")))
+ (keymap-sym (intern (concat mode-str "-map"))))
+ ;; FIXME: Don't add lambdas to hooks. Instead give names to
+ ;; those functions and add the symbol to the hook. Makes it
+ ;; easier/possible to remove/update the function on the hook.
+ (var:add-and-run-hook hook-sym
+ (lambda ()
+ (let ((syntax-table (symbol-value
syntax-table-sym))
+ (keymap (symbol-value keymap-sym)))
+ (modify-syntax-entry ?\< "(>" syntax-table)
+ (modify-syntax-entry ?\> ")<" syntax-table)
+ (modify-syntax-entry ?\{ "(}" syntax-table)
+ (modify-syntax-entry ?\} "){" syntax-table)
+ (modify-syntax-entry ?\" "\"" syntax-table)
+ (modify-syntax-entry ?= "." syntax-table)
+ (modify-syntax-entry ?. "_" syntax-table)
+ (setq sentence-end "\\([^
\t\n\r>]<\\|>\\(<[^>]*>\\)*\\|[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)\\)[ \t\n]*")
+ (define-key keymap "\C-c."
#'hui-select-goto-matching-tag))))
+ (unless (eq mode 'web-mode)
+ (var:add-and-run-hook
+ hook-sym (lambda ()
+ ;; FIXME: Why not rely on the major mode's own settings?
+ (make-local-variable 'comment-end) ;FIXME: Why?
+ (setq-local comment-start "<!--" comment-end "-->")
+ (make-local-variable 'sentence-end) ;FIXME: Why?
+ ))))))
(defun hui-select-get-region-boundaries ()
"Return the (START . END) boundaries of region for `hui-select-thing'."
@@ -472,7 +474,7 @@ displayed in the minibuffer."
;;;###autoload
(defun hui-select-goto-matching-tag ()
"Move point to start of the tag paired with closest tag point is at or
precedes.
-Enabled in major modes in `hui-select-markup-modes. Returns t if
+Enabled in major modes in `hui-select-markup-modes'. Returns t if
point is moved, else nil. Signals an error if no tag is found
following point or if the closing tag does not have a `>'
terminator character."
- [elpa] scratch/hyperbole 5206d3b3d4 01/16: * hload-path.el (hyperb:dir): Use `macroexp-file-name`, (continued)
- [elpa] scratch/hyperbole 5206d3b3d4 01/16: * hload-path.el (hyperb:dir): Use `macroexp-file-name`, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 0bf8fd8eee 03/16: Try and avoid using `hyperb:stack-frame`, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole b5780234d9 02/16: * hversion.el (hyperb:path-being-loaded): Delete function, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 60cf4b3ab0 07/16: * hact.el: Fix broken lexical-binding cookie, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 57d02f8456 09/16: hyperbole-autoloads.el: Remove needless definitions, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 5aa8d7a577 10/16: * hycontrol.el (hycontrol-windows-mode-map): Don't autoload, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole fd3f79a9ee 15/16: * hargs.el (hargs:set-string-to-complete): Don't mess with windows, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole ab0338d714 05/16: Fix compilation of test file, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 63e463172e 06/16: (kview:char-visible-p): Delete function, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole fbcfcc04a3 08/16: * hyperbole.el: Preload `kotl-autoloads`, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole fc7e33b5e5 11/16: * hui-select.el: Fix a few warnings and improve some docstrings,
Stefan Monnier <=
- [elpa] scratch/hyperbole 12fa8e328d 12/16: (man-show): Fix miscompilation, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 10ac3f59df 13/16: Fix a few minor miscompilations and warnings, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 02335b71bd 14/16: * hyrolo.el: A few cosmetic tweaks, Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole a269d1536e 16/16: * hversion.el: Add FIXMEs., Stefan Monnier, 2023/06/19
- [elpa] scratch/hyperbole 824a71773c 04/16: Get rid of `hyperb:stack-frame`, Stefan Monnier, 2023/06/19