emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 1331467: Allow eval-ing named character literals


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 1331467: Allow eval-ing named character literals
Date: Mon, 02 May 2016 21:59:25 +0000

branch: master
commit 1331467910537f4d85fa842c993ef2c48ebbf749
Author: Philipp Stephani <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Allow eval-ing named character literals
    
    * lisp/progmodes/elisp-mode.el (elisp--preceding-sexp): Skip over
    named character literals.
    * test/lisp/progmodes/elisp-mode-tests.el
    (elisp--preceding-sexp--char-name): Add test for skipping over
    named character literals (bug#23354).
    
    Copyright-paperwork-exempt: yes
---
 lisp/progmodes/elisp-mode.el            |   11 +++++++++++
 test/lisp/progmodes/elisp-mode-tests.el |    6 ++++++
 2 files changed, 17 insertions(+)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index ca85980..1c72848 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1051,6 +1051,17 @@ If CHAR is not a character, return nil."
              ((or (eq (following-char) ?\')
                   (eq (preceding-char) ?\'))
               (setq left-quote ?\`)))
+
+        ;; When after a named character literal, skip over the entire
+        ;; literal, not only its last word.
+        (when (= (preceding-char) ?})
+          (let ((begin (save-excursion
+                         (backward-char)
+                         (skip-syntax-backward "w-")
+                         (backward-char 3)
+                         (when (looking-at-p "\\\\N{") (point)))))
+            (when begin (goto-char begin))))
+
        (forward-sexp -1)
        ;; If we were after `?\e' (or similar case),
        ;; use the whole thing, not just the `e'.
diff --git a/test/lisp/progmodes/elisp-mode-tests.el 
b/test/lisp/progmodes/elisp-mode-tests.el
index 1679af3..a7562a0 100644
--- a/test/lisp/progmodes/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -641,5 +641,11 @@ to (xref-elisp-test-descr-to-target xref)."
   (elisp--xref-find-definitions (eval '(provide 'stephe-leake-feature)))
   nil)
 
+(ert-deftest elisp--preceding-sexp--char-name ()
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (insert "?\\N{HEAVY CHECK MARK}")
+    (should (equal (elisp--preceding-sexp) ?\N{HEAVY CHECK MARK}))))
+
 (provide 'elisp-mode-tests)
 ;;; elisp-mode-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]