From 90c6880a922029ba6e57adb2afe00a6fa57ef7fe Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 17 Oct 2024 11:39:19 -0400 Subject: [PATCH 1/5] (track-changes--after): Fix problem found in bug#73041 When calling `track-changes--before` (e.g. because of a missing b-f-c or for some other reason), it sets `track-changes--before-end` to the right value so we shouldn't increment it right after. Also, we should update `track-changes--buffer-size` before calling `track-changes--before` so it doesn't risk signaling a spurious inconsistency. * lisp/emacs-lisp/track-changes.el (track-changes--after): Update `track-changes--buffer-size` earlier, and don't increment `track-changes--before-end` when we call `track-changes--before`. --- lisp/emacs-lisp/track-changes.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lisp/emacs-lisp/track-changes.el b/lisp/emacs-lisp/track-changes.el index 92d14959763..1d5c5e9917a 100644 --- a/lisp/emacs-lisp/track-changes.el +++ b/lisp/emacs-lisp/track-changes.el @@ -555,16 +555,16 @@ Details logged to `track-changes--error-log'") (defun track-changes--after (beg end len) (cl-assert track-changes--state) - (and (eq track-changes--before-clean 'unset) - (not track-changes--before-no) - ;; This can be a sign that a `before-change-functions' went missing, - ;; or that we called `track-changes--clean-state' between - ;; a `before-change-functions' and `after-change-functions'. - (track-changes--before beg end)) - (setq track-changes--before-clean nil) (let ((offset (- (- end beg) len))) - (cl-incf track-changes--before-end offset) (cl-incf track-changes--buffer-size offset) + (if (and (eq track-changes--before-clean 'unset) + (not track-changes--before-no)) + ;; This can be a sign that a `before-change-functions' went missing, + ;; or that we called `track-changes--clean-state' between + ;; a `before-change-functions' and `after-change-functions'. + (track-changes--before beg end) + (cl-incf track-changes--before-end offset)) + (setq track-changes--before-clean nil) (if (not (or track-changes--before-no (save-restriction (widen) From e5d600006e2b283923044d2c139b29dd69f5ac30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= Date: Thu, 17 Oct 2024 14:06:20 +0200 Subject: [PATCH 2/5] ; * src/doc.c (Ftext_quoting_style): Make doc string agree with code. --- src/doc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc.c b/src/doc.c index 7bff8bd8edb..fdb61be2097 100644 --- a/src/doc.c +++ b/src/doc.c @@ -669,7 +669,7 @@ If the variable `text-quoting-style' is `grave', `straight' or `curve', just return that value. If it is nil (the default), return `grave' if curved quotes cannot be displayed (for instance, on a terminal with no support for these characters), otherwise return -`quote'. Any other value is treated as `grave'. +`curve'. Any other value is treated as `curve'. Note that in contrast to the variable `text-quoting-style', this function will never return nil. */) From 2c640e63a8a6ea9f2fbbb55ff44d7a8a0ec0f4b4 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Fri, 18 Oct 2024 11:22:52 +0200 Subject: [PATCH 3/5] Explain tty-color-mode frame parameter more. * doc/emacs/cmdargs.texi (Colors X): Explain that tty color support is dynamic. * doc/lispref/frames.texi (Font and Color Parameters): Explain that 'tty-color-mode' can be changed on the fly. * doc/misc/efaq.texi (Colors on a TTY): Explain how to disable 'tty-color-mode', either at startup or dynamically. --- doc/emacs/cmdargs.texi | 6 +++++- doc/lispref/frames.texi | 2 +- doc/misc/efaq.texi | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index ba4b45d272b..9b72b883628 100644 --- a/doc/emacs/cmdargs.texi +++ b/doc/emacs/cmdargs.texi @@ -1027,7 +1027,11 @@ there is no mode that supports @var{num} colors, Emacs acts as if @var{num} were 0, i.e., it uses the terminal's default color support mode. @end table -If @var{mode} is omitted, it defaults to @var{ansi8}. +If @var{mode} is omitted, it defaults to @var{ansi8}. This support is +dynamic: the current mode is available via the @code{tty-color-mode} +frame parameter, and it can be changed by modifying that frame parameter. +This means you can also specify the initial value via +@code{default-frame-alist} instead of the command-line option. @end table For example, to use a coral mouse cursor and a slate blue text cursor, diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 8744687a531..694f33af8ee 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -2447,7 +2447,7 @@ off color support. If the parameter's value is a symbol, it specifies a number through the value of @code{tty-color-mode-alist}, and the associated number is -used instead. +used instead. This parameter supports dynamic changes. @vindex screen-gamma@r{, a frame parameter} @item screen-gamma diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index 8c3b81a5fe5..8a7a11071da 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -1880,6 +1880,21 @@ think that your terminal supports colors, but Emacs won't use them, check the @code{termcap} entry for your display type for color-related capabilities. +If by contrast you wish to @emph{disable} tty color support, either +start emacs with the @samp{--color=no} command-line option, or ensure +that the frame parameter @code{tty-color-mode} is @code{no}, e.g. by +putting the following in your init file: + +@lisp +(push '(tty-color-mode . no) default-frame-alist) +@end lisp + +To disable tty color support in the @emph{current} frame you can run: + +@lisp +(set-frame-parameter nil 'tty-color-mode 'no) +@end lisp + The command @kbd{M-x list-colors-display} pops up a window which exhibits all the colors Emacs knows about on the current display. From 19049efd30f5476baa4b69c4b79af15674c2650b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 18 Oct 2024 15:46:17 +0300 Subject: [PATCH 4/5] ; Fix last documentation change * doc/misc/efaq.texi (Colors on a TTY): * doc/lispref/frames.texi (Font and Color Parameters): * doc/emacs/cmdargs.texi (Colors X): More accurate documentation of TTY color modes and 'tty-color-mode' frame parameter. (Bug#73813) --- doc/emacs/cmdargs.texi | 18 ++++++++++++++---- doc/lispref/frames.texi | 3 ++- doc/misc/efaq.texi | 7 ++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index 9b72b883628..08e67c891a5 100644 --- a/doc/emacs/cmdargs.texi +++ b/doc/emacs/cmdargs.texi @@ -1027,10 +1027,20 @@ there is no mode that supports @var{num} colors, Emacs acts as if @var{num} were 0, i.e., it uses the terminal's default color support mode. @end table -If @var{mode} is omitted, it defaults to @var{ansi8}. This support is -dynamic: the current mode is available via the @code{tty-color-mode} -frame parameter, and it can be changed by modifying that frame parameter. -This means you can also specify the initial value via + +This option has no effect on MS-Windows and MS-DOS. + +@cindex colors on character terminal, changing during session +@cindex character terminal, change color mode +@vindex tty-color-mode@r{, frame parameter} +If @var{mode} is omitted, it defaults to @var{ansi8}. + +The color mode can be changed dynamically during a running Emacs +session: the current mode is available via the @code{tty-color-mode} +frame parameter, and it can be changed by modifying that frame +parameter.@footnote{ +This does not work on MS-Windows and MS-DOS text-mode terminals. +} This means you can also specify the initial value via @code{default-frame-alist} instead of the command-line option. @end table diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 694f33af8ee..fccc40d4ccc 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -2447,7 +2447,8 @@ off color support. If the parameter's value is a symbol, it specifies a number through the value of @code{tty-color-mode-alist}, and the associated number is -used instead. This parameter supports dynamic changes. +used instead. This parameter supports dynamic changes during a running +Emacs session (but not on MS-Windows and MS-DOS). @vindex screen-gamma@r{, a frame parameter} @item screen-gamma diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi index 8a7a11071da..1fe006c1249 100644 --- a/doc/misc/efaq.texi +++ b/doc/misc/efaq.texi @@ -1889,12 +1889,17 @@ putting the following in your init file: (push '(tty-color-mode . no) default-frame-alist) @end lisp -To disable tty color support in the @emph{current} frame you can run: +@noindent +To disable tty color support in the @emph{current} frame you can +evaluate: @lisp (set-frame-parameter nil 'tty-color-mode 'no) @end lisp +Note that this currently doesn't work on MS-Windows and MS-DOS, whose +text-mode terminals always use the fixed number of 16 text colors. + The command @kbd{M-x list-colors-display} pops up a window which exhibits all the colors Emacs knows about on the current display. From 7dbbd58d6c9cafde2136b83ff149aa608203e207 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Fri, 18 Oct 2024 17:47:43 +0200 Subject: [PATCH 5/5] Locate password icon in global-mode-string * doc/emacs/mini.texi (Passwords): Precise the location of the password icon. * doc/lispref/minibuf.texi (Reading a Password): The password icon is added to global-mode-string. * lisp/auth-source.el (read-passwd--mode-line-buffer): Remove. (read-passwd--hide-password): Fix docstring. (read-passwd-toggle-visibility): Don't use `read-passwd--mode-line-buffer'. Check for `read-passwd-mode'. Force update in all mode lines. (read-passwd-mode): Set `read-passwd--mode-line-icon' in `global-mode-string'. (Bug#73768) --- doc/emacs/mini.texi | 4 ++-- doc/lispref/minibuf.texi | 6 +++--- lisp/auth-source.el | 38 ++++++++++++++------------------------ 3 files changed, 19 insertions(+), 29 deletions(-) diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi index 3be9b76ad88..b1361695211 100644 --- a/doc/emacs/mini.texi +++ b/doc/emacs/mini.texi @@ -975,8 +975,8 @@ password. You may type either @key{RET} or @key{ESC} to submit the password. Any other self-inserting character key inserts the associated character into the password, and all other input is ignored. - There is also an icon at the front of the mode line indicating the -password visibility. Clicking @kbd{mouse-1} on it toggles the password + There is also an icon in the mode line indicating the password +visibility. Clicking @kbd{mouse-1} on it toggles the password visibility as well. @node Yes or No Prompts diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index f0b7fef30c7..c5b9176d628 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi @@ -2562,9 +2562,9 @@ This function uses @code{read-passwd-mode}, a minor mode. It binds two keys in the minbuffer: @kbd{C-u} (@code{delete-minibuffer-contents}) deletes the password, and @kbd{TAB} (@code{read-passwd--toggle-visibility}) toggles the visibility of the -password. There is also an additional icon in the mode-line. Clicking -on this icon with @key{mouse-1} toggles the visibility of the password -as well. +password. There is also an additional icon in the mode-line's +@code{global-mode-string}. Clicking on this icon with @key{mouse-1} +toggles the visibility of the password as well. @end defun @node Minibuffer Commands diff --git a/lisp/auth-source.el b/lisp/auth-source.el index 90b58f560c0..557d360bc6a 100644 --- a/lisp/auth-source.el +++ b/lisp/auth-source.el @@ -2467,14 +2467,11 @@ point is moved into the passwords (see `authinfo-hide-elements'). :version "30.1" :help-echo "mouse-1: Toggle password visibility") -(defvar read-passwd--mode-line-buffer nil - "Buffer to modify `mode-line-format' for showing/hiding passwords.") - (defvar read-passwd--mode-line-icon nil "Propertized mode line icon for showing/hiding passwords.") (defvar read-passwd--hide-password t - "Toggle whether password should be hidden in minubuffer.") + "Toggle whether password should be hidden in minibuffer.") (defun read-passwd--hide-password () "Make password in minibuffer hidden or visible." @@ -2497,8 +2494,8 @@ Adapt also mode line." ;; FIXME: In case of a recursive minibuffer, this may select the wrong ;; mini-buffer. (with-current-buffer (window-buffer win) - (setq read-passwd--hide-password (not read-passwd--hide-password)) - (with-current-buffer read-passwd--mode-line-buffer + (when (memq 'read-passwd-mode local-minor-modes) + (setq read-passwd--hide-password (not read-passwd--hide-password)) (setq read-passwd--mode-line-icon `(:propertize ,(if icon-preference @@ -2514,8 +2511,8 @@ Adapt also mode line." (define-key map [mode-line mouse-1] #'read-passwd-toggle-visibility) map)))) - (force-mode-line-update)) - (read-passwd--hide-password)))) + (force-mode-line-update 'all) + (read-passwd--hide-password))))) (defvar read-passwd-map ;; BEWARE: `defconst' would purecopy it, breaking the sharing with @@ -2534,25 +2531,18 @@ Adapt also mode line." :keymap read-passwd-map :version "30.1" - (setq read-passwd--hide-password nil - ;; Stolen from `eldoc-minibuffer-message'. - read-passwd--mode-line-buffer - (window-buffer - (or (window-in-direction 'above (minibuffer-window)) - (minibuffer-selected-window) - (get-largest-window)))) + (setq read-passwd--hide-password nil) + (or global-mode-string (setq global-mode-string '(""))) - (if read-passwd-mode - (with-current-buffer read-passwd--mode-line-buffer + (let ((mode-string '(:eval read-passwd--mode-line-icon))) + (if read-passwd-mode ;; Add `read-passwd--mode-line-icon'. - (when (listp mode-line-format) - (setq mode-line-format - (cons '(:eval read-passwd--mode-line-icon) - mode-line-format)))) - (with-current-buffer read-passwd--mode-line-buffer + (or (member mode-string global-mode-string) + (setq global-mode-string + (append global-mode-string (list mode-string)))) ;; Remove `read-passwd--mode-line-icon'. - (when (listp mode-line-format) - (setq mode-line-format (cdr mode-line-format))))) + (setq global-mode-string + (delete mode-string global-mode-string)))) (when read-passwd-mode (read-passwd-toggle-visibility)))