1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00

Compare commits

...

4 commits

Author SHA1 Message Date
Kristoffer Balintona
21f9295aa9 Improve performance of 'flyspell-goto-next-error'
* lisp/textmodes/flyspell.el (flyspell-goto-next-error): Use
'next-overlay-change' and 'previous-overlay-change'.
(Bug#79933)
2025-12-04 14:19:51 +02:00
Rudolf Adamkovič
cbf9c58730 NS: Fix toolbar style and position
* src/nsterm.m ([EmacsWindow initWithEmacsFrame:fullscreen:screen:]):
Always show the toolbar below the window title.  This is needed on
Mac OS 11+ where the toolbar style is decided by the system (which
is unpredictable) and the newfangled "compact" toolbar may be chosen
(which is undesirable).  (Bug#79900)
2025-12-04 14:16:35 +02:00
Eli Zaretskii
6a4ca5e59b ; Avoid assertion violations in 'font-match-p'
* src/font.c (font_match_p): Avoid assertion violations in
'font_encode_char' if FONT is not a font-object.
2025-12-04 10:11:09 +02:00
Stephen Gildea
7f04e046fb ; time-stamp: factor out two small, internal utilities
* lisp/time-stamp.el (time-stamp--message, time-stamp--system-name):
New utility functions.
(time-stamp, time-stamp-once, time-stamp-string-preprocess):
Call the new functions.
2025-12-03 23:44:45 -08:00
5 changed files with 49 additions and 42 deletions

View file

@ -1748,17 +1748,11 @@ FLYSPELL-BUFFER."
(setq pos (point))) (setq pos (point)))
;; Seek the next error. ;; Seek the next error.
(while (and (/= pos max) (while (and (/= pos max)
(let ((ovs (overlays-at pos)) (setq pos (if previous
(r '())) (previous-overlay-change pos)
(while (and (not r) (consp ovs)) (next-overlay-change pos)))
(if (flyspell-overlay-p (car ovs)) (not (any #'flyspell-overlay-p (overlays-at pos)))))
(setq r t)
(setq ovs (cdr ovs))))
(not r)))
(setq pos (if previous (1- pos) (1+ pos))))
(goto-char pos) (goto-char pos)
(when previous
(forward-word -1))
;; Save the current location for next invocation. ;; Save the current location for next invocation.
(setq flyspell-old-pos-error (point)) (setq flyspell-old-pos-error (point))
(setq flyspell-old-buffer-error (current-buffer)) (setq flyspell-old-buffer-error (current-buffer))

View file

@ -117,7 +117,7 @@ limit yourself to the formats recommended by that older version."
(defcustom time-stamp-active t (defcustom time-stamp-active t
"Non-nil enables time-stamping of buffers by \\[time-stamp]. "Non-nil enables time-stamping of buffers by \\[time-stamp].
Can be toggled by \\[time-stamp-toggle-active] as an easy way to Can be toggled by \\[time-stamp-toggle-active] as an easy way to
temporarily disable time-stamp while saving a file. temporarily disable `time-stamp' while saving a file.
This option does not affect when `time-stamp' is run, only what it This option does not affect when `time-stamp' is run, only what it
does when it runs. To activate automatic time-stamping of buffers does when it runs. To activate automatic time-stamping of buffers
@ -377,12 +377,10 @@ to customize the information in the time stamp and where it is written."
(setq ts-end (match-string 6 time-stamp-pattern))))) (setq ts-end (match-string 6 time-stamp-pattern)))))
(cond ((not (integerp line-limit)) (cond ((not (integerp line-limit))
(setq line-limit 8) (setq line-limit 8)
(message "time-stamp-line-limit is not an integer") (time-stamp--message "time-stamp-line-limit is not an integer")))
(sit-for 1)))
(cond ((not (integerp ts-count)) (cond ((not (integerp ts-count))
(setq ts-count 1) (setq ts-count 1)
(message "time-stamp-count is not an integer") (time-stamp--message "time-stamp-count is not an integer"))
(sit-for 1))
((< ts-count 1) ((< ts-count 1)
;; We need to call time-stamp-once at least once ;; We need to call time-stamp-once at least once
;; to output any warnings about time-stamp not being active. ;; to output any warnings about time-stamp not being active.
@ -395,8 +393,7 @@ to customize the information in the time stamp and where it is written."
(cond (cond
((not (and (stringp ts-start) ((not (and (stringp ts-start)
(stringp ts-end))) (stringp ts-end)))
(message "time-stamp-start or time-stamp-end is not a string") (time-stamp--message "time-stamp-start or time-stamp-end is not a string"))
(sit-for 1))
(t (t
(let ((nl-start 0)) (let ((nl-start 0))
(while (string-match "\n" ts-end nl-start) (while (string-match "\n" ts-end nl-start)
@ -466,10 +463,8 @@ Returns the end point, which is where `time-stamp' begins the next search."
(cond (cond
((not time-stamp-active) ((not time-stamp-active)
(if time-stamp-warn-inactive (if time-stamp-warn-inactive
;; don't signal an error in a hook (time-stamp--message
(progn "Warning: time-stamp-active is off; did not time-stamp buffer."))
(message "Warning: time-stamp-active is off; did not time-stamp buffer.")
(sit-for 1)))
nil) nil)
(t (t
(let ((new-time-stamp (time-stamp-string ts-format))) (let ((new-time-stamp (time-stamp-string ts-format)))
@ -753,7 +748,7 @@ and all `time-stamp-format' compatibility."
time-stamp-no-file)) time-stamp-no-file))
((eq cur-char ?s) ;system name, legacy ((eq cur-char ?s) ;system name, legacy
(time-stamp-conv-warn "%s" "%Q") (time-stamp-conv-warn "%s" "%Q")
(system-name)) (time-stamp--system-name :full))
((eq cur-char ?u) ;user name, legacy ((eq cur-char ?u) ;user name, legacy
(time-stamp-conv-warn "%u" "%l") (time-stamp-conv-warn "%u" "%l")
(user-login-name)) (user-login-name))
@ -765,16 +760,13 @@ and all `time-stamp-format' compatibility."
((eq cur-char ?L) ;full name of logged-in user ((eq cur-char ?L) ;full name of logged-in user
(user-full-name)) (user-full-name))
((eq cur-char ?h) ;mail host name ((eq cur-char ?h) ;mail host name
(or mail-host-address (system-name))) (or mail-host-address (time-stamp--system-name :full)))
((or (eq cur-char ?q) ;unqualified host name ((or (eq cur-char ?q) ;unqualified host name
(eq cur-char ?x)) ;short system name, experimental (eq cur-char ?x)) ;short system name, experimental
(let ((shortname (system-name))) (time-stamp--system-name :short))
(if (string-match "\\." shortname)
(substring shortname 0 (match-beginning 0))
shortname)))
((or (eq cur-char ?Q) ;fully-qualified host name ((or (eq cur-char ?Q) ;fully-qualified host name
(eq cur-char ?X)) ;full system name, experimental (eq cur-char ?X)) ;full system name, experimental
(system-name)) (time-stamp--system-name :full))
)) ))
(if (numberp field-result) (if (numberp field-result)
(progn (progn
@ -838,7 +830,7 @@ This is an internal helper for `time-stamp-string-preprocess'."
(defun time-stamp-filtered-buffer-file-name (type) (defun time-stamp-filtered-buffer-file-name (type)
"Return a printable string representing the buffer file name. "Return a printable string representing the buffer file name.
Non-graphic characters are replaced by ?. TYPE is :absolute Non-graphic characters are replaced by ?. TYPE is :absolute
for the full name or :nondirectory for base name only." for the full name or :nondirectory for base name only."
(declare (ftype (function ((member :absolute :nondirectory)) string))) (declare (ftype (function ((member :absolute :nondirectory)) string)))
(let ((file-name buffer-file-name) (let ((file-name buffer-file-name)
@ -857,6 +849,18 @@ for the full name or :nondirectory for base name only."
(setq file-name (file-name-nondirectory file-name))) (setq file-name (file-name-nondirectory file-name)))
(apply #'string (mapcar safe-character-filter file-name)))) (apply #'string (mapcar safe-character-filter file-name))))
(defun time-stamp--message (warning-string)
"Display WARNING-STRING for one second."
(message "%s" warning-string)
(sit-for 1))
(defun time-stamp--system-name (type)
"Return the host name of this system.
TYPE is :short for the unqualified name, :full for the full name."
(let ((fullname (system-name)))
(if (and (eq type :short) (string-match "\\." fullname))
(substring fullname 0 (match-beginning 0))
fullname)))
(defvar time-stamp-conversion-warn t (defvar time-stamp-conversion-warn t
"Enable warnings for old formats in `time-stamp-format'. "Enable warnings for old formats in `time-stamp-format'.

View file

@ -2488,6 +2488,8 @@ font_match_p (Lisp_Object spec, Lisp_Object font)
val2 = XCDR (val2); val2 = XCDR (val2);
if (CONSP (val2)) if (CONSP (val2))
{ {
if (! FONT_OBJECT_P (font))
return 0;
/* All characters in the list must be supported. */ /* All characters in the list must be supported. */
for (; CONSP (val2); val2 = XCDR (val2)) for (; CONSP (val2); val2 = XCDR (val2))
{ {
@ -2500,6 +2502,8 @@ font_match_p (Lisp_Object spec, Lisp_Object font)
} }
else if (VECTORP (val2)) else if (VECTORP (val2))
{ {
if (! FONT_OBJECT_P (font))
return 0;
/* At most one character in the vector must be supported. */ /* At most one character in the vector must be supported. */
for (i = 0; i < ASIZE (val2); i++) for (i = 0; i < ASIZE (val2); i++)
{ {

View file

@ -9562,6 +9562,13 @@ ns_in_echo_area (void)
#ifdef NS_IMPL_COCOA #ifdef NS_IMPL_COCOA
if ([self respondsToSelector:@selector(setTabbingMode:)]) if ([self respondsToSelector:@selector(setTabbingMode:)])
[self setTabbingMode:NSWindowTabbingModeDisallowed]; [self setTabbingMode:NSWindowTabbingModeDisallowed];
#endif
/* Always show the toolbar below the window title. This is needed
on Mac OS 11+ where the toolbar style is decided by the system
(which is unpredictable) and the newfangled "compact" toolbar
may be chosen (which is undesirable). */
#ifdef NS_IMPL_COCOA
[self setToolbarStyle: NSWindowToolbarStyleExpanded];
#endif #endif
} }

View file

@ -40,14 +40,9 @@
(lambda (old-format _new &optional _newer) (lambda (old-format _new &optional _newer)
(ert-fail (ert-fail
(format "Unexpected format warning for '%s'" old-format)))) (format "Unexpected format warning for '%s'" old-format))))
((symbol-function 'message) ((symbol-function 'time-stamp--message)
(lambda (format-string &rest args) (lambda (msg)
(ert-fail (format "Unexpected message: %s" (ert-fail (format "Unexpected message: %s" msg)))))
(apply #'format format-string args)))))
((symbol-function 'sit-for)
(lambda (&rest _args)
;; do not wait during tests
)))
;; Not all reference times are used in all tests; ;; Not all reference times are used in all tests;
;; suppress the byte compiler's "unused" warning. ;; suppress the byte compiler's "unused" warning.
(list ref-time1 ref-time2 ref-time3) (list ref-time1 ref-time2 ref-time3)
@ -65,10 +60,13 @@
,@body))) ,@body)))
(defmacro with-time-stamp-system-name (name &rest body) (defmacro with-time-stamp-system-name (name &rest body)
"Force function `system-name' to return NAME while evaluating BODY." "Force `time-stamp--system-name' to return NAME while evaluating BODY."
(declare (indent 1) (debug t)) (declare (indent 1) (debug t))
`(cl-letf (((symbol-function 'system-name) `(cl-letf (((symbol-function 'time-stamp--system-name)
(lambda () ,name))) (lambda (type)
(if (and (eq type :short) (string-match "\\." ,name))
(substring ,name 0 (match-beginning 0))
,name))))
,@body)) ,@body))
@ -92,10 +90,10 @@
(should ,form))) (should ,form)))
(defmacro time-stamp-should-message (variable &rest body) (defmacro time-stamp-should-message (variable &rest body)
"Output a message about VARIABLE if `message' is not called by BODY." "Fail test about VARIABLE if BODY does not call `time-stamp--message'."
(declare (indent 1) (debug t)) (declare (indent 1) (debug t))
`(time-stamp-test--count-function-calls `(time-stamp-test--count-function-calls
message (format "variable %s" ',variable) time-stamp--message (format "variable %s" ',variable)
,@body)) ,@body))
;;; Tests: ;;; Tests: