[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master c2aaa8f15aa 2/8: Process read-symbol-shorthands from longest to s
From: |
João Távora |
Subject: |
master c2aaa8f15aa 2/8: Process read-symbol-shorthands from longest to shortest (bug#67390) |
Date: |
Sat, 3 Feb 2024 09:44:07 -0500 (EST) |
branch: master
commit c2aaa8f15aa8fb3415a6c9f421f539ee34b7f52c
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Process read-symbol-shorthands from longest to shortest (bug#67390)
This ensures that overlapping shorthands are handled correctly and
consistently even if specified out-of-order by the user.
* doc/lispref/symbols.texi (Shorthands): Describe shorthand sort
order.
* lisp/files.el (hack-local-variables--find-variables): Specially
handle read-symbol-shorthands.
---
doc/lispref/symbols.texi | 17 +++++++++++++++++
lisp/files.el | 7 +++++++
2 files changed, 24 insertions(+)
diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi
index 367bd195f16..e95e53d972d 100644
--- a/doc/lispref/symbols.texi
+++ b/doc/lispref/symbols.texi
@@ -761,6 +761,23 @@ instead of @code{snu-}.
;; End:
@end example
+Note that if you have two shorthands in the same file where one is the
+prefix of the other, the longer shorthand will be attempted first.
+This happens regardless of the order you specify shorthands in the
+local variables section of your file.
+
+@example
+'(
+ t//foo ; reads to 'my-tricks--foo', not 'my-tricks-/foo'
+ t/foo ; reads to 'my-tricks-foo'
+ )
+
+;; Local Variables:
+;; read-symbol-shorthands: (("t/" . "my-tricks-")
+;; ("t//" . "my-tricks--")
+;; End:
+@end example
+
@subsection Exceptions
There are two exceptions to rules governing Shorthand transformations:
diff --git a/lisp/files.el b/lisp/files.el
index fd9088206d7..172237ceb82 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4191,6 +4191,13 @@ major-mode."
;; to use 'thisbuf's name in the
;; warning message.
(or (buffer-file-name thisbuf) ""))))))
+ ((eq var 'read-symbol-shorthands)
+ ;; Sort automatically by shorthand length
+ ;; descending
+ (setq val (sort val
+ (lambda (sh1 sh2) (> (length (car
sh1))
+ (length (car
sh2))))))
+ (push (cons 'read-symbol-shorthands val) result))
((and (eq var 'mode) handle-mode))
(t
(ignore-errors
- master updated (25bf8d3cdc6 -> f266622cdb3), João Távora, 2024/02/03
- master c2aaa8f15aa 2/8: Process read-symbol-shorthands from longest to shortest (bug#67390),
João Távora <=
- master 17c3610c561 3/8: Consider read-symbol-shorthands in check-declare.el (bug#67523), João Távora, 2024/02/03
- master 817140a852e 6/8: Fix prefix discovery for files with read-symbol-shorthands (bug#67325), João Távora, 2024/02/03
- master 9a51fbb69fc 7/8: ; Also consider shorthands in check-declare-scan (bug#67523), João Távora, 2024/02/03
- master 5e4a0a29fa3 1/8: Make sure read-symbol-shorthands is permanently local, João Távora, 2024/02/03
- master 0f715f9c154 4/8: Improve shorthands-font-lock-shorthands (bug#67390), João Távora, 2024/02/03
- master c52d17d91ad 5/8: Also teach loaddefs-gen.el about shorthands (bug#63480), João Távora, 2024/02/03
- master f266622cdb3 8/8: ; Optimize shorthand insertion in loaddefs-generate--parse-file, João Távora, 2024/02/03