1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

Merge from origin/emacs-30

ecfebb5abb ; Always set 'emoji--insert-buffer'
35e356f958 Fix font-lock of last character before EOB under 'whitesp...
01ebe6de89 Fix 'whitespace-mode' with 'missing-newline-at-eof'
This commit is contained in:
Eli Zaretskii 2024-09-21 07:32:38 -04:00
commit ff2cc0fc23
2 changed files with 23 additions and 11 deletions

View File

@ -164,12 +164,12 @@ when the command was invoked."
(let ((buf (current-buffer))) (let ((buf (current-buffer)))
(emoji--init) (emoji--init)
(switch-to-buffer (get-buffer-create "*Emoji*")) (switch-to-buffer (get-buffer-create "*Emoji*"))
(setq-local emoji--insert-buffer buf)
;; Don't regenerate the buffer if it already exists -- this will ;; Don't regenerate the buffer if it already exists -- this will
;; leave point where it was the last time it was used. ;; leave point where it was the last time it was used.
(when (zerop (buffer-size)) (when (zerop (buffer-size))
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(emoji-list-mode) (emoji-list-mode)
(setq-local emoji--insert-buffer buf)
(emoji--list-generate nil (cons nil emoji--labels)) (emoji--list-generate nil (cons nil emoji--labels))
(goto-char (point-min)))))) (goto-char (point-min))))))

View File

@ -739,7 +739,7 @@ This variable is used when `whitespace-style' includes
(defcustom whitespace-indentation-regexp (defcustom whitespace-indentation-regexp
'("^\t*\\(\\( \\{%d\\}\\)+\\)[^\n\t]" '("^\t*\\(\\( \\{%d\\}\\)+\\)[^\n\t]"
. "^ *\\(\t+\\)[^\n]") . "^ *\\(\t+\\).")
"Regexps to match indentation whitespace that should be visualized. "Regexps to match indentation whitespace that should be visualized.
The value should be a cons whose car specifies the regexp to match The value should be a cons whose car specifies the regexp to match
@ -1752,7 +1752,7 @@ cleaning up these problems."
((eq (car option) 'space-after-tab::space) ((eq (car option) 'space-after-tab::space)
(whitespace-space-after-tab-regexp 'space)) (whitespace-space-after-tab-regexp 'space))
((eq (car option) 'missing-newline-at-eof) ((eq (car option) 'missing-newline-at-eof)
"[^\n]\\'") ".\\'")
(t (t
(cdr option))))) (cdr option)))))
(when (re-search-forward regexp rend t) (when (re-search-forward regexp rend t)
@ -2188,14 +2188,14 @@ resultant list will be returned."
1 whitespace-space-after-tab t))) 1 whitespace-space-after-tab t)))
,@(when (memq 'missing-newline-at-eof whitespace-active-style) ,@(when (memq 'missing-newline-at-eof whitespace-active-style)
;; Show missing newline. ;; Show missing newline.
`(("[^\n]\\'" 0 `((".\\'" 0
;; Don't mark the end of the buffer is point is there -- ;; Don't mark the end of the buffer if point is there --
;; it probably means that the user is typing something ;; it probably means that the user is typing something
;; at the end of the buffer. ;; at the end of the buffer.
(and (/= whitespace-point (point-max)) (and (/= whitespace-point (point-max))
'whitespace-missing-newline-at-eof) 'whitespace-missing-newline-at-eof)
t))))) prepend)))))
(font-lock-add-keywords nil whitespace-font-lock-keywords t) (font-lock-add-keywords nil whitespace-font-lock-keywords 'append)
(font-lock-flush))) (font-lock-flush)))
@ -2333,10 +2333,22 @@ Also refontify when necessary."
(font-lock-flush whitespace-eob-marker (1+ (buffer-size))))) (font-lock-flush whitespace-eob-marker (1+ (buffer-size)))))
(setq-local whitespace-buffer-changed nil) (setq-local whitespace-buffer-changed nil)
(setq whitespace-point (point)) ; current point position (setq whitespace-point (point)) ; current point position
(let ((refontify (and (eolp) ; It is at end of line ... (let ((refontify (or (and (eolp) ; It is at end of line ...
;; ... with trailing SPACE or TAB ;; ... with trailing SPACE or TAB
(or (memq (preceding-char) '(?\s ?\t))) (or (memq (preceding-char) '(?\s ?\t)))
(line-beginning-position))) (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))) (ostart (overlay-start whitespace-point--used)))
(cond (cond
((not refontify) ((not refontify)