From 01ebe6de8954b2381bfba31038a0bd0669e33910 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 21 Sep 2024 13:41:21 +0300 Subject: [PATCH 1/3] Fix 'whitespace-mode' with 'missing-newline-at-eof' * lisp/whitespace.el (whitespace-post-command-hook): Refontify when point moves if 'missing-newline-at-eof' is in 'whitespace-active-style'. (Bug#73332) --- lisp/whitespace.el | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lisp/whitespace.el b/lisp/whitespace.el index bc23a8794eb..f4ee7ab1c10 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -2319,10 +2319,22 @@ Also refontify when necessary." (font-lock-flush whitespace-eob-marker (1+ (buffer-size))))) (setq-local whitespace-buffer-changed nil) (setq whitespace-point (point)) ; current point position - (let ((refontify (and (eolp) ; It is at end of line ... - ;; ... with trailing SPACE or TAB - (or (memq (preceding-char) '(?\s ?\t))) - (line-beginning-position))) + (let ((refontify (or (and (eolp) ; It is at end of line ... + ;; ... with trailing SPACE or TAB + (or (memq (preceding-char) '(?\s ?\t))) + (line-beginning-position)) + (and (memq 'missing-newline-at-eof + ;; If user requested to highlight + ;; EOB without a newline... + whitespace-active-style) + ;; ...and the buffer is not empty... + (not (= (point-min) (point-max))) + (= (point-max) (without-restriction (point-max))) + ;; ...and no newline at EOB... + (not (eq (char-before (point-max)) ?\n)) + ;; ...then refontify the last character in + ;; the buffer + (max (1- (point-max)) (point-min))))) (ostart (overlay-start whitespace-point--used))) (cond ((not refontify) From 35e356f958af69baad8a1a824c59993915fb6abe Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 19 Sep 2024 11:50:26 -0400 Subject: [PATCH 2/3] Fix font-lock of last character before EOB under 'whitespace-mode' * lisp/whitespace.el (whitespace-color-on): Don't use OVERRIDE in font-lock-keywords; instead, use 'prepend' in the call to 'font-lock-add-keywords'. (Bug#73332) --- lisp/whitespace.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/whitespace.el b/lisp/whitespace.el index f4ee7ab1c10..8be139d4584 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -739,7 +739,7 @@ This variable is used when `whitespace-style' includes (defcustom whitespace-indentation-regexp '("^\t*\\(\\( \\{%d\\}\\)+\\)[^\n\t]" - . "^ *\\(\t+\\)[^\n]") + . "^ *\\(\t+\\).") "Regexps to match indentation whitespace that should be visualized. The value should be a cons whose car specifies the regexp to match @@ -1738,7 +1738,7 @@ cleaning up these problems." ((eq (car option) 'space-after-tab::space) (whitespace-space-after-tab-regexp 'space)) ((eq (car option) 'missing-newline-at-eof) - "[^\n]\\'") + ".\\'") (t (cdr option))))) (when (re-search-forward regexp rend t) @@ -2174,14 +2174,14 @@ resultant list will be returned." 1 whitespace-space-after-tab t))) ,@(when (memq 'missing-newline-at-eof whitespace-active-style) ;; Show missing newline. - `(("[^\n]\\'" 0 - ;; Don't mark the end of the buffer is point is there -- + `((".\\'" 0 + ;; Don't mark the end of the buffer if point is there -- ;; it probably means that the user is typing something ;; at the end of the buffer. (and (/= whitespace-point (point-max)) 'whitespace-missing-newline-at-eof) - t))))) - (font-lock-add-keywords nil whitespace-font-lock-keywords t) + prepend))))) + (font-lock-add-keywords nil whitespace-font-lock-keywords 'append) (font-lock-flush))) From ecfebb5abb864d568a90ff4a1420c973781bbef9 Mon Sep 17 00:00:00 2001 From: Scott Bell Date: Fri, 20 Sep 2024 14:16:52 -0700 Subject: [PATCH 3/3] ; Always set 'emoji--insert-buffer' * lisp/international/emoji.el (emoji-list): Always set insert buffer. (Bug#73390) Copyright-paperwork-exempt: yes --- lisp/international/emoji.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/international/emoji.el b/lisp/international/emoji.el index cbf7c547f4c..e8cd869a571 100644 --- a/lisp/international/emoji.el +++ b/lisp/international/emoji.el @@ -164,12 +164,12 @@ when the command was invoked." (let ((buf (current-buffer))) (emoji--init) (switch-to-buffer (get-buffer-create "*Emoji*")) + (setq-local emoji--insert-buffer buf) ;; Don't regenerate the buffer if it already exists -- this will ;; leave point where it was the last time it was used. (when (zerop (buffer-size)) (let ((inhibit-read-only t)) (emoji-list-mode) - (setq-local emoji--insert-buffer buf) (emoji--list-generate nil (cons nil emoji--labels)) (goto-char (point-min))))))