2
(message "Shynur: Hi!")
\N{BOX DRAWINGS LIGHT HORIZONTAL}■
;;             cursor RIGHT HERE ^
;;             then type "C-x C-e"

"C-x C-e" skips those characters that make up an illegal syntax.

Is it a defined behavior? If so, where is it documented?

shynur
  • 4,065
  • 1
  • 3
  • 23
  • what's the major mode? – SparedWhisle Jul 10 '23 at 09:57
  • @SparedWhisle: lisp-interact..., elisp, text, etc. – shynur Jul 10 '23 at 10:01
  • @Drew: "*Comments can be deleted at any time...*" -- Yes. But which major mode I use is useless information because the crux has nothing to do with these major modes. I can `C-x C-e` anywhere, no? – shynur Jul 10 '23 at 14:58
  • 2
    Interesting question and answer. What's more, `pp-eval-last-sexp` evaluates `HORIZONTAL}` as the last sexp, and thus raises an error, saying it's an unbound variable. – Drew Jul 10 '23 at 15:06
  • Yes, you're right about the mode. – Drew Jul 10 '23 at 15:07

1 Answers1

3
;;; elisp-mode.el ...

(defun elisp--preceding-sexp ()
  "Return sexp before the point."
  ...
        ;; 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))))

It indeed skips...

I think this code snippet is written for ?\N{...} syntax, and it assumes that users always evaluate proper forms.

Fixed:

                         ;; (backward-char 3)
                         (backward-char 4)
                         ;; (when (looking-at-p "\\\\N{") (point)))))
                         (when (looking-at-p "\\?\\\\N{") (point)))))
            ;; (when begin (goto-char begin))))
            (when begin (goto-char (1+ begin)))))
shynur
  • 4,065
  • 1
  • 3
  • 23