Merge from origin/emacs-29

ec00d292ec Improve treesit-fontify-with-override
4bcdb1cc65 Make killing a non-last client work the same no matter th...
a27f61f6f4 Use the function 'window-system' on the tab-bar/tab-line ...
432b9655ae Restore font-lock-type-face for lisp mode &symbols
This commit is contained in:
Stefan Kangas 2022-12-05 06:30:21 +01:00
commit 4fa37dc426
8 changed files with 83 additions and 65 deletions

View file

@ -514,7 +514,7 @@ This will generate compile-time constants from BINDINGS."
(0 font-lock-builtin-face))
;; ELisp and CLisp `&' keywords as types.
(,(lambda (bound) (lisp-mode--search-key "&" bound))
(0 font-lock-builtin-face))
(0 font-lock-type-face))
;; ELisp regexp grouping constructs
(,(lambda (bound)
(catch 'found
@ -567,7 +567,7 @@ This will generate compile-time constants from BINDINGS."
(0 font-lock-builtin-face))
;; ELisp and CLisp `&' keywords as types.
(,(lambda (bound) (lisp-mode--search-key "&" bound))
(0 font-lock-builtin-face))
(0 font-lock-type-face))
;; ELisp regexp grouping constructs
;; This is too general -- rms.
;; A user complained that he has functions whose names start with `do'

View file

@ -360,12 +360,11 @@ For NODE, OVERRIDE, START, END, and ARGS, see
override start end args))
((or "identifier" "field_identifier")
(treesit-fontify-with-override
(max (treesit-node-start node) start)
(min (treesit-node-end node) end)
(treesit-node-start node) (treesit-node-end node)
(pcase (treesit-node-type (treesit-node-parent node))
("function_declarator" 'font-lock-function-name-face)
(_ 'font-lock-variable-name-face))
override))))
override start end))))
(defun c-ts-mode--fontify-variable (node override start end &rest _)
"Fontify an identifier node.
@ -375,10 +374,8 @@ OVERRIDE, START, END, and ARGS, see `treesit-font-lock-rules'."
(treesit-node-parent node))
"call_expression"))
(treesit-fontify-with-override
(max (treesit-node-start node) start)
(min (treesit-node-end node) end)
'font-lock-variable-name-face
override)))
(treesit-node-start node) (treesit-node-end node)
'font-lock-variable-name-face override start end)))
(defun c-ts-mode--fontify-defun (node override start end &rest _)
"Correctly fontify the DEFUN macro.
@ -405,21 +402,19 @@ This function corrects the fontification on the colon in
(when (equal (treesit-node-text node t) ":")
(treesit-fontify-with-override
(treesit-node-start node) (treesit-node-end node)
'default override)))
'default override start end)))
;; Fix the parameter list.
(while arg-list-2
(let ((type (and arg-list-2 (pop arg-list-2)))
(arg (and arg-list-2 (pop arg-list-2))))
(when type
(treesit-fontify-with-override
(max start (treesit-node-start type))
(min end (treesit-node-end type))
'font-lock-type-face override))
(treesit-node-start type) (treesit-node-end type)
'font-lock-type-face override start end))
(when arg
(treesit-fontify-with-override
(max start (treesit-node-start arg))
(min end (treesit-node-end arg))
'default override))))))
(treesit-node-start arg) (treesit-node-end arg)
'default override start end))))))
(defun c-ts-fontify-error (node override start end &rest _)
"Fontify the error nodes.
@ -428,8 +423,7 @@ For NODE, OVERRIDE, START, and END, see
(let ((parent (treesit-node-parent node))
(child (treesit-node-child node 0)))
(treesit-fontify-with-override
(max start (treesit-node-start node))
(min end (treesit-node-end node))
(treesit-node-start node) (treesit-node-end node)
(cond
;; This matches the case MACRO(struct a, b, c)
;; where struct is seen as error.
@ -439,7 +433,7 @@ For NODE, OVERRIDE, START, and END, see
'("struct" "long" "short" "enum" "union")))
'font-lock-keyword-face)
(t 'font-lock-warning-face))
override)))
override start end)))
(defun c-ts-mode--imenu-1 (node)
"Helper for `c-ts-mode--imenu'.

View file

@ -3647,7 +3647,7 @@ OVERRIDE is the override flag described in
(setq font-beg (max start font-beg))
(when (< font-beg end)
(treesit-fontify-with-override
font-beg font-end 'font-lock-string-face override)))
font-beg font-end 'font-lock-string-face override start end)))
(setq font-beg (treesit-node-end child)
child (treesit-node-next-sibling child)))))

View file

@ -1069,7 +1069,7 @@ fontified."
(when (eq (char-after string-beg) ?f)
(cl-incf string-beg))
(treesit-fontify-with-override
(max start string-beg) (min end string-end) face override)))
string-beg string-end face override start end)))
(defvar python--treesit-settings
(treesit-font-lock-rules

View file

@ -1780,29 +1780,43 @@ With ARG non-nil, silently save all file-visiting buffers, then kill.
If emacsclient was started with a list of filenames to edit, then
only these files will be asked to be saved."
(if server-stop-automatically
(server-stop-automatically--handle-delete-frame (selected-frame))
(let ((proc (frame-parameter nil 'client)))
(cond ((eq proc 'nowait)
;; Nowait frames have no client buffer list.
(if (cdr (frame-list))
(progn (save-some-buffers arg)
(delete-frame))
;; If we're the last frame standing, kill Emacs.
(save-buffers-kill-emacs arg)))
((processp proc)
(let ((buffers (process-get proc 'buffers)))
(save-some-buffers
arg (if buffers
;; Only files from emacsclient file list.
(lambda () (memq (current-buffer) buffers))
;; No emacsclient file list: don't override
;; `save-some-buffers-default-predicate' (unless
;; ARG is non-nil), since we're not killing
;; Emacs (unlike `save-buffers-kill-emacs').
(and arg t)))
(server-delete-client proc)))
(t (error "Invalid client frame"))))))
(let ((proc (frame-parameter nil 'client)))
(cond ((eq proc 'nowait)
;; Nowait frames have no client buffer list.
(if (length> (frame-list) (if server-stop-automatically 2 1))
;; If there are any other frames, only delete this one.
;; When `server-stop-automatically' is set, don't count
;; the daemon frame.
(progn (save-some-buffers arg)
(delete-frame))
;; If we're the last frame standing, kill Emacs.
(save-buffers-kill-emacs arg)))
((processp proc)
(if (or (not server-stop-automatically)
(length> server-clients 1)
(seq-some
(lambda (frame)
(when-let ((p (frame-parameter frame 'client)))
(not (eq proc p))))
(frame-list)))
;; If `server-stop-automatically' is not enabled, there
;; are any other clients, or there are frames not owned
;; by the current client (e.g. `nowait' frames), then
;; we just want to delete this client.
(let ((buffers (process-get proc 'buffers)))
(save-some-buffers
arg (if buffers
;; Only files from emacsclient file list.
(lambda () (memq (current-buffer) buffers))
;; No emacsclient file list: don't override
;; `save-some-buffers-default-predicate' (unless
;; ARG is non-nil), since we're not killing
;; Emacs (unlike `save-buffers-kill-emacs').
(and arg t)))
(server-delete-client proc))
;; Otherwise, we want to kill Emacs.
(save-buffers-kill-emacs arg)))
(t (error "Invalid client frame")))))
(defun server-stop-automatically--handle-delete-frame (frame)
"Handle deletion of FRAME when `server-stop-automatically' is used."

View file

@ -586,7 +586,7 @@ and `tab-bar-select-tab-modifiers'."
(defun tab-bar-separator ()
"Separator between tabs."
(or tab-bar-separator (if window-system " " "|")))
(or tab-bar-separator (if (window-system) " " "|")))
(defcustom tab-bar-tab-name-function #'tab-bar-tab-name-current
@ -939,7 +939,7 @@ when the tab is current. Return the result as a keymap."
(str (propertize " " 'display
;; The `right' spec doesn't work on TTY frames
;; when windows are split horizontally (bug#59620)
(if window-system
(if (window-system)
`(space :align-to (- right (,hpos)))
`(space :align-to (,(- (frame-inner-width) hpos)))))))
`((align-right menu-item ,str ignore))))
@ -1060,11 +1060,11 @@ tab bar might wrap to the second line when it shouldn't.")
(string-pixel-width non-tabs))
(length tabs)))
(when tab-bar-auto-width-min
(setq width (max width (if window-system
(setq width (max width (if (window-system)
(nth 0 tab-bar-auto-width-min)
(nth 1 tab-bar-auto-width-min)))))
(when tab-bar-auto-width-max
(setq width (min width (if window-system
(setq width (min width (if (window-system)
(nth 0 tab-bar-auto-width-max)
(nth 1 tab-bar-auto-width-max)))))
(dolist (item tabs)

View file

@ -504,7 +504,7 @@ which the tab will represent."
(defun tab-line-format-template (tabs)
"Template of the format for displaying tab line for selected window.
This is used by `tab-line-format'."
(let* ((separator (or tab-line-separator (if window-system " " "|")))
(let* ((separator (or tab-line-separator (if (window-system) " " "|")))
(hscroll (window-parameter nil 'tab-line-hscroll))
(strings
(mapcar

View file

@ -774,25 +774,35 @@ signals the `treesit-font-lock-error' error if that happens."
((memq feature remove-list) nil)
(t current-value))))))
(defun treesit-fontify-with-override (start end face override)
(defun treesit-fontify-with-override
(start end face override &optional bound-start bound-end)
"Apply FACE to the region between START and END.
OVERRIDE can be nil, t, `append', `prepend', or `keep'.
See `treesit-font-lock-rules' for their semantic."
(pcase override
('nil (unless (text-property-not-all
start end 'face nil)
(put-text-property start end 'face face)))
('t (put-text-property start end 'face face))
('append (font-lock-append-text-property
See `treesit-font-lock-rules' for their semantic.
If BOUND-START and BOUND-END are non-nil, only fontify the region
in between them."
(when (or (null bound-start) (null bound-end)
(and bound-start bound-end
(<= bound-start end)
(>= bound-end start)))
(when (and bound-start bound-end)
(setq start (max bound-start start)
end (min bound-end end)))
(pcase override
('nil (unless (text-property-not-all start end 'face nil)
(put-text-property start end 'face face)))
('t (put-text-property start end 'face face))
('append (font-lock-append-text-property
start end 'face face))
('prepend (font-lock-prepend-text-property
start end 'face face))
('keep (font-lock-fillin-text-property
start end 'face face))
('prepend (font-lock-prepend-text-property
start end 'face face))
('keep (font-lock-fillin-text-property
start end 'face face))
(_ (signal 'treesit-font-lock-error
(list
"Unrecognized value of :override option"
override)))))
(_ (signal 'treesit-font-lock-error
(list
"Unrecognized value of :override option"
override))))))
(defun treesit--set-nonsticky (start end sym &optional remove)
"Set `rear-nonsticky' property between START and END.