[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bugfix/shorthand-fixes e184e15285b 2/6: Process read-symbol-shorthands f
From: |
João Távora |
Subject: |
bugfix/shorthand-fixes e184e15285b 2/6: Process read-symbol-shorthands from longest to shortest (bug#67390) |
Date: |
Thu, 30 Nov 2023 09:05:49 -0500 (EST) |
branch: bugfix/shorthand-fixes
commit e184e15285b70d744dac5667ea934832d12879e9
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 1f3b677d7fb..18e80311177 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 1717d1eeeff..b266d0727ec 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4172,6 +4172,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
- branch bugfix/shorthand-fixes created (now 7e99ed2f539), João Távora, 2023/11/30
- bugfix/shorthand-fixes 3c6719f55c1 1/6: Make sure read-symbol-shorthands is permanently local, João Távora, 2023/11/30
- bugfix/shorthand-fixes d1e8e9d4054 3/6: Consider read-symbol-shorthands in check-declare.el (bug#67523), João Távora, 2023/11/30
- bugfix/shorthand-fixes 7e99ed2f539 6/6: Fix prefix discovery for files with read-symbol-shorthands (bug#67325), João Távora, 2023/11/30
- bugfix/shorthand-fixes ff48f1401d2 5/6: Also teach loaddefs-gen.el about shorthands (bug#63480), João Távora, 2023/11/30
- bugfix/shorthand-fixes 48f5bd5d744 4/6: Improve shorthands-font-lock-shorthands (bug#67390), João Távora, 2023/11/30
- bugfix/shorthand-fixes e184e15285b 2/6: Process read-symbol-shorthands from longest to shortest (bug#67390),
João Távora <=