]> code.delx.au - gnu-emacs/commitdiff
Allow eval-ing named character literals
authorPhilipp Stephani <p.stephani2@gmail.com>
Mon, 2 May 2016 21:58:15 +0000 (23:58 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 2 May 2016 21:58:15 +0000 (23:58 +0200)
* 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
test/lisp/progmodes/elisp-mode-tests.el

index ca85980c28e12e95fc8dff9695956cdb9fdd8825..1c728484ab56caf07764be6cee53b547a935259b 100644 (file)
@@ -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'.
index 1679af308213b8d74bfe2d61d50349a607288388..a7562a00c88417788a99a69b77f38dd4b81e2d7e 100644 (file)
@@ -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