commit 9fc935f1225f75eb36091060b02a583cf32ff30c (HEAD, refs/remotes/origin/master) Author: Mattias Engdegård Date: Sat Jun 6 11:23:48 2020 +0200 Use 65535 as color-values scale value in the NS backend * src/nsfns.m (Fxw_color_values): Scale with 65535 instead of 65280, for uniformity with other backends. * lisp/faces.el (color-values): Update doc string. * doc/lispref/frames.texi (Color Names): Update examples. diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 6bf5db2aa1..966f620558 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -3975,11 +3975,11 @@ If @var{color} is not defined, the value is @code{nil}. (color-values "black") @result{} (0 0 0) (color-values "white") - @result{} (65280 65280 65280) + @result{} (65535 65535 65535) (color-values "red") - @result{} (65280 0 0) + @result{} (65535 0 0) (color-values "pink") - @result{} (65280 49152 51968) + @result{} (65535 49344 52171) (color-values "hungry") @result{} nil @end example diff --git a/lisp/faces.el b/lisp/faces.el index e707f6f4b6..f4a9dedd79 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -1822,7 +1822,7 @@ COLOR should be a string naming a color (e.g. \"white\"), or a string specifying a color's RGB components (e.g. \"#ff12ec\"). Return a list of three integers, (RED GREEN BLUE), each between 0 -and either 65280 or 65535 (the maximum depends on the system). +and 65535 inclusive. Use `color-name-to-rgb' if you want RGB floating-point values normalized to 1.0. diff --git a/src/nsfns.m b/src/nsfns.m index 273fb5f759..628233ea0d 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -2329,8 +2329,8 @@ Frames are listed from topmost (first) to bottommost (last). */) [[col colorUsingDefaultColorSpace] getRed: &red green: &green blue: &blue alpha: &alpha]; unblock_input (); - return list3i (lrint (red * 65280), lrint (green * 65280), - lrint (blue * 65280)); + return list3i (lrint (red * 65535), lrint (green * 65535), + lrint (blue * 65535)); } commit 788cd6d8b98c0e7750e478ae84e580f29576b5ff Author: Juri Linkov Date: Sun Jun 7 02:42:24 2020 +0300 The key prefix 'C-x t t' displays next command buffer in a new tab (bug#41691) * lisp/tab-bar.el (other-tab-prefix): New command. (tab-prefix-map): Bind key 'C-x t t' to other-tab-prefix. * lisp/windmove.el (windmove-display-in-direction): Use display-buffer-override-next-command. * lisp/window.el (display-buffer-override-next-command): New function refactored from windmove-display-in-direction. diff --git a/etc/NEWS b/etc/NEWS index edad5b37d6..6e94d4a91b 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -109,6 +109,10 @@ setting the variable 'auto-save-visited-mode' buffer-locally to nil. * Changes in Specialized Modes and Packages in Emacs 28.1 +** Tab Bars + +*** The key prefix 'C-x t t' displays next command buffer in a new tab. + ** New bindings in occur-mode, 'next-error-no-select' bound to 'n' and 'previous-error-no-select' bound to 'p'. diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 76e7f8c33a..eb3ad72db4 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1575,6 +1575,25 @@ Like \\[find-file-other-frame] (which see), but creates a new tab." value) (switch-to-buffer-other-tab value)))) +(defun other-tab-prefix () + "Display the buffer of the next command in a new tab. +The next buffer is the buffer displayed by the next command invoked +immediately after this command (ignoring reading from the minibuffer). +Creates a new tab before displaying the buffer, or switches to the tab +that already contains that buffer. +When `switch-to-buffer-obey-display-actions' is non-nil, +`switch-to-buffer' commands are also supported." + (interactive) + (display-buffer-override-next-command + (lambda (buffer alist) + (cons (progn + (display-buffer-in-tab + buffer (append alist '((inhibit-same-window . nil) + (reusable-frames . t)))) + (selected-window)) + 'tab))) + (message "Display next command buffer in a new tab...")) + (define-key tab-prefix-map "2" 'tab-new) (define-key tab-prefix-map "1" 'tab-close-other) (define-key tab-prefix-map "0" 'tab-close) @@ -1585,6 +1604,7 @@ Like \\[find-file-other-frame] (which see), but creates a new tab." (define-key tab-prefix-map "b" 'switch-to-buffer-other-tab) (define-key tab-prefix-map "f" 'find-file-other-tab) (define-key tab-prefix-map "\C-f" 'find-file-other-tab) +(define-key tab-prefix-map "t" 'other-tab-prefix) (provide 'tab-bar) diff --git a/lisp/windmove.el b/lisp/windmove.el index f96383197b..341c739d92 100644 --- a/lisp/windmove.el +++ b/lisp/windmove.el @@ -461,60 +461,38 @@ select the window with a displayed buffer, and the meaning of the prefix argument is reversed. When `switch-to-buffer-obey-display-actions' is non-nil, `switch-to-buffer' commands are also supported." - (let* ((no-select (xor (consp arg) windmove-display-no-select)) - (old-window (or (minibuffer-selected-window) (selected-window))) - (new-window) - (minibuffer-depth (minibuffer-depth)) - (action (lambda (buffer alist) - (unless (> (minibuffer-depth) minibuffer-depth) - (let* ((type 'reuse) - (window (cond - ((eq dir 'new-tab) - (let ((tab-bar-new-tab-choice t)) - (tab-bar-new-tab)) - (setq type 'tab) - (selected-window)) - ((eq dir 'new-frame) - (let* ((params (cdr (assq 'pop-up-frame-parameters alist))) - (pop-up-frame-alist (append params pop-up-frame-alist)) - (frame (make-frame-on-current-monitor - pop-up-frame-alist))) - (unless (cdr (assq 'inhibit-switch-frame alist)) - (window--maybe-raise-frame frame)) - (setq type 'frame) - (frame-selected-window frame))) - ((eq dir 'same-window) - (selected-window)) - (t (window-in-direction - dir nil nil - (and arg (prefix-numeric-value arg)) - windmove-wrap-around))))) - (unless window - (setq window (split-window nil nil dir) type 'window)) - (setq new-window (window--display-buffer buffer window - type alist)))))) - (command this-command) - (clearfun (make-symbol "clear-display-buffer-overriding-action")) - (exitfun - (lambda () - (setq display-buffer-overriding-action - (delq action display-buffer-overriding-action)) - (when (window-live-p (if no-select old-window new-window)) - (select-window (if no-select old-window new-window))) - (remove-hook 'post-command-hook clearfun)))) - (fset clearfun - (lambda () - (unless (or - ;; Remove the hook immediately - ;; after exiting the minibuffer. - (> (minibuffer-depth) minibuffer-depth) - ;; But don't remove immediately after - ;; adding the hook by the same command below. - (eq this-command command)) - (funcall exitfun)))) - (add-hook 'post-command-hook clearfun) - (push action display-buffer-overriding-action) - (message "[display-%s]" dir))) + (let ((no-select (xor (consp arg) windmove-display-no-select))) + (display-buffer-override-next-command + (lambda (_buffer alist) + (let* ((type 'reuse) + (window (cond + ((eq dir 'new-tab) + (let ((tab-bar-new-tab-choice t)) + (tab-bar-new-tab)) + (setq type 'tab) + (selected-window)) + ((eq dir 'new-frame) + (let* ((params (cdr (assq 'pop-up-frame-parameters alist))) + (pop-up-frame-alist (append params pop-up-frame-alist)) + (frame (make-frame-on-current-monitor + pop-up-frame-alist))) + (unless (cdr (assq 'inhibit-switch-frame alist)) + (window--maybe-raise-frame frame)) + (setq type 'frame) + (frame-selected-window frame))) + ((eq dir 'same-window) + (selected-window)) + (t (window-in-direction + dir nil nil + (and arg (prefix-numeric-value arg)) + windmove-wrap-around))))) + (unless window + (setq window (split-window nil nil dir) type 'window)) + (cons window type))) + (lambda (old-window new-window) + (when (window-live-p (if no-select old-window new-window)) + (select-window (if no-select old-window new-window)))))) + (message "[display-%s]" dir)) ;;;###autoload (defun windmove-display-left (&optional arg) diff --git a/lisp/window.el b/lisp/window.el index d658cb81f6..998568e7b8 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -8578,6 +8578,47 @@ documentation for additional customization information." (interactive (list (read-buffer-to-switch "Switch to buffer in other frame: "))) (pop-to-buffer buffer-or-name display-buffer--other-frame-action norecord)) + +(defun display-buffer-override-next-command (pre-function &optional post-function) + "Set `display-buffer-overriding-action' for the next command. +`pre-function' is called to prepare the window where the buffer should be +displayed. This function takes two arguments `buffer' and `alist', and +should return a cons with the displayed window and its type. See the +meaning of these values in `window--display-buffer'. +Optional `post-function' is called after the buffer is displayed in the +window; the function takes two arguments: an old and new window." + (let* ((old-window (or (minibuffer-selected-window) (selected-window))) + (new-window nil) + (minibuffer-depth (minibuffer-depth)) + (action (lambda (buffer alist) + (unless (> (minibuffer-depth) minibuffer-depth) + (let* ((ret (funcall pre-function buffer alist)) + (window (car ret)) + (type (cdr ret))) + (setq new-window (window--display-buffer buffer window + type alist)))))) + (command this-command) + (clearfun (make-symbol "clear-display-buffer-overriding-action")) + (exitfun + (lambda () + (setq display-buffer-overriding-action + (delq action display-buffer-overriding-action)) + (remove-hook 'post-command-hook clearfun) + (when (functionp post-function) + (funcall post-function old-window new-window))))) + (fset clearfun + (lambda () + (unless (or + ;; Remove the hook immediately + ;; after exiting the minibuffer. + (> (minibuffer-depth) minibuffer-depth) + ;; But don't remove immediately after + ;; adding the hook by the same command below. + (eq this-command command)) + (funcall exitfun)))) + (add-hook 'post-command-hook clearfun) + (push action display-buffer-overriding-action))) + (defun set-window-text-height (window height) "Set the height in lines of the text display area of WINDOW to HEIGHT. commit 7ac79872aed63110c0d26c1e62e1838d6101c9bd Author: Paul Eggert Date: Sat Jun 6 12:05:10 2020 -0700 make-text-button no longer modifies its string arg * etc/NEWS: Mention this. * lisp/apropos.el (apropos-library-button): * lisp/ibuf-ext.el (ibuffer-old-saved-filters-warning): There’s no longer a need copy make-text-button’s string arg. * lisp/button.el (make-text-button): Return a copy of a string arg. Delay making the copy until after error-checking. diff --git a/etc/NEWS b/etc/NEWS index 27e511047e..edad5b37d6 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -476,6 +476,11 @@ are 'eq'. To compare contents, use 'compare-window-configurations' instead. This change helps fix a bug in 'sxhash-equal', which returned incorrect hashes for window configurations and some other objects. +** When its first argument is a string, 'make-text-button' no longer +modifies the string's text properties; instead, it uses and returns +a copy of the string. This helps avoid trouble when strings are +shared or constants. + --- ** The obsolete function 'thread-alive-p' has been removed. diff --git a/lisp/apropos.el b/lisp/apropos.el index 22866cd2cc..2566d44dfc 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el @@ -661,7 +661,7 @@ Return list of symbols and documentation found." (defun apropos-library-button (sym) (if (null sym) "" - (let ((name (copy-sequence (symbol-name sym)))) + (let ((name (symbol-name sym))) (make-text-button name nil 'type 'apropos-library 'face 'apropos-symbol diff --git a/lisp/button.el b/lisp/button.el index 3a6a6de774..d9c36a0375 100644 --- a/lisp/button.el +++ b/lisp/button.el @@ -341,15 +341,14 @@ If the property `button-data' is present, it will later be used as the argument for the `action' callback function instead of the default argument, which is the button itself. -BEG can also be a string, in which case it is made into a button. +BEG can also be a string, in which case a copy of it is made into +a button and returned. Also see `insert-text-button'." (let ((object nil) (type-entry (or (plist-member properties 'type) (plist-member properties :type)))) - (when (stringp beg) - (setq object beg beg 0 end (length object))) ;; Disallow setting the `category' property directly. (when (plist-get properties 'category) (error "Button `category' property may not be set directly")) @@ -362,6 +361,10 @@ Also see `insert-text-button'." (setcar type-entry 'category) (setcar (cdr type-entry) (button-category-symbol (cadr type-entry)))) + (when (stringp beg) + (setq object (copy-sequence beg)) + (setq beg 0) + (setq end (length object))) ;; Now add all the text properties at once. (add-text-properties beg end ;; Each button should have a non-eq `button' diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index c39000b488..bfb9787a96 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -202,7 +202,7 @@ The format has been repaired and the variable modified accordingly. You can save the current value through the customize system by either clicking or hitting return " (make-text-button - (copy-sequence "here") nil + "here" nil 'face '(:weight bold :inherit button) 'mouse-face '(:weight normal :background "gray50" :inherit button) 'follow-link t commit 8bcc781bc762b4082cfd678b88938e3d03465d91 Author: Basil L. Contovounesios Date: Wed Jun 3 17:35:59 2020 +0100 Un-deprecate oset and oset-default For discussion see the following threads: https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg00630.html https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg00674.html https://lists.gnu.org/archive/html/emacs-devel/2020-06/msg00099.html * lisp/emacs-lisp/eieio.el (oset, oset-default): Un-deprecate. * lisp/emacs-lisp/eieio-core.el (eieio-oref): Declare gv-setter here instead of in lisp/emacs-lisp/eieio.el. Suggested by Stefan Monnier . (eieio-oref-default): Add gv-setter declaration. * etc/NEWS: Announce these changes. * doc/misc/eieio.texi (Accessing Slots): Document oref and oref-default as generalized variables. Consistently document getters before setters. * test/lisp/emacs-lisp/eieio-tests/eieio-tests.el: Use lexical-binding. (eieio-test-13-init-methods): Simplify. (eieio-test-33-instance-tracker): Declare IT-list as special. diff --git a/doc/misc/eieio.texi b/doc/misc/eieio.texi index 3943c544c7..6e7d4386be 100644 --- a/doc/misc/eieio.texi +++ b/doc/misc/eieio.texi @@ -698,6 +698,27 @@ and argument-order conventions are similar to those used for referencing vectors (@pxref{Vectors,,,elisp,GNU Emacs Lisp Reference Manual}). +@defmac oref obj slot +@anchor{oref} +This macro retrieves the value stored in @var{obj} in the named +@var{slot}. Slot names are determined by @code{defclass} which +creates the slot. + +This is a generalized variable that can be used with @code{setf} to +modify the value stored in @var{slot}. @xref{Generalized +Variables,,,elisp,GNU Emacs Lisp Reference Manual}. +@end defmac + +@defmac oref-default class slot +@anchor{oref-default} +This macro returns the value of the class-allocated @var{slot} from +@var{class}. + +This is a generalized variable that can be used with @code{setf} to +modify the value stored in @var{slot}. @xref{Generalized +Variables,,,elisp,GNU Emacs Lisp Reference Manual}. +@end defmac + @defmac oset object slot value This macro sets the value behind @var{slot} to @var{value} in @var{object}. It returns @var{value}. @@ -716,17 +737,6 @@ changed, this can be arranged by simply executing this bit of code: @end example @end defmac -@defmac oref obj slot -@anchor{oref} -Retrieve the value stored in @var{obj} in the slot named by @var{slot}. -Slot is the name of the slot when created by @dfn{defclass}. -@end defmac - -@defmac oref-default class slot -@anchor{oref-default} -Get the value of the class-allocated @var{slot} from @var{class}. -@end defmac - The following accessors are defined by CLOS to reference or modify slot values, and use the previously mentioned set/ref routines. diff --git a/etc/NEWS b/etc/NEWS index ed4722b27f..27e511047e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -112,7 +112,12 @@ setting the variable 'auto-save-visited-mode' buffer-locally to nil. ** New bindings in occur-mode, 'next-error-no-select' bound to 'n' and 'previous-error-no-select' bound to 'p'. -** EIEIO: 'oset' and 'oset-default' are declared obsolete. +** EIEIO + ++++ +*** The macro 'oref-default' can now be used with 'setf'. +It is now defined as a generalized variable that can be used with +'setf' to modify the value stored in a given class slot. ** New minor mode 'cl-font-lock-built-in-mode' for `lisp-mode'. The mode provides refined highlighting of built-in functions, types, diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 1e53f30a2a..3bc65d0d4c 100644 --- a/lisp/emacs-lisp/eieio-core.el +++ b/lisp/emacs-lisp/eieio-core.el @@ -730,7 +730,8 @@ Argument FN is the function calling this verifier." (guard (not (memq name eieio--known-slot-names)))) (macroexp--warn-and-return (format-message "Unknown slot `%S'" name) exp 'compile-only)) - (_ exp))))) + (_ exp)))) + (gv-setter eieio-oset)) (cl-check-type slot symbol) (cl-check-type obj (or eieio-object class)) (let* ((class (cond ((symbolp obj) @@ -755,6 +756,7 @@ Argument FN is the function calling this verifier." (defun eieio-oref-default (obj slot) "Do the work for the macro `oref-default' with similar parameters. Fills in OBJ's SLOT with its default value." + (declare (gv-setter eieio-oset-default)) (cl-check-type obj (or eieio-object class)) (cl-check-type slot symbol) (let* ((cl (cond ((symbolp obj) (cl--find-class obj)) diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index ee5dd2cccd..b75410ee22 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -513,8 +513,7 @@ The CLOS function `class-direct-subclasses' is aliased to this function." "Set the value in OBJ for slot SLOT to VALUE. SLOT is the slot name as specified in `defclass' or the tag created with in the :initarg slot. VALUE can be any Lisp object." - (declare (obsolete "use (setf (oref ..) ..) instead" "28.1") - (debug (form symbolp form))) + (declare (debug (form symbolp form))) `(eieio-oset ,obj (quote ,slot) ,value)) (defmacro oset-default (class slot value) @@ -522,8 +521,7 @@ with in the :initarg slot. VALUE can be any Lisp object." The default value is usually set with the :initform tag during class creation. This allows users to change the default behavior of classes after they are created." - (declare (obsolete "use (setf (oref-default ..) ..) instead" "28.1") - (debug (form symbolp form))) + (declare (debug (form symbolp form))) `(eieio-oset-default ,class (quote ,slot) ,value)) ;;; CLOS queries into classes and slots @@ -647,14 +645,6 @@ If SLOT is unbound, do nothing." nil (eieio-oset object slot (delete item (eieio-oref object slot))))) -;;; Here are some CLOS items that need the CL package -;; - -;; FIXME: Shouldn't this be a more complex gv-expander which extracts the -;; common code between oref and oset, so as to reduce the redundant work done -;; in (push foo (oref bar baz)), like we do for the `nth' expander? -(gv-define-simple-setter eieio-oref eieio-oset) - ;;; ;; We want all objects created by EIEIO to have some default set of diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el index 34c20b2003..21adc91e55 100644 --- a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el +++ b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el @@ -1,4 +1,4 @@ -;;; eieio-tests.el -- eieio tests routines +;;; eieio-tests.el -- eieio test routines -*- lexical-binding: t -*- ;; Copyright (C) 1999-2003, 2005-2010, 2012-2020 Free Software ;; Foundation, Inc. @@ -356,7 +356,7 @@ METHOD is the method that was attempting to be called." (oset a test-tag 1)) (let ((ca (class-a))) - (should-not (/= (oref ca test-tag) 2)))) + (should (= (oref ca test-tag) 2)))) ;;; Perform slot testing @@ -852,6 +852,7 @@ Subclasses to override slot attributes.") "Instance Tracker test object.") (ert-deftest eieio-test-33-instance-tracker () + (defvar IT-list) (let (IT-list IT1) (should (setq IT1 (IT))) ;; The instance tracker must find this