commit 636e9fd6a0c6b7801fd5a0d58fd42c93aab7332d (HEAD, refs/remotes/origin/master) Author: Junya Takahashi Date: Mon Apr 12 10:14:11 2021 +0200 Fix args-out-of-range error in epa-file-insert-file-contents * lisp/epa-file.el (epa-file-insert-file-contents): Don't bug out on a region that's longer than the file (bug#47718). Copyright-paperwork-exempt: yes diff --git a/lisp/epa-file.el b/lisp/epa-file.el index e46e3684c8..33bf5adabe 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -198,7 +198,9 @@ encryption is used." (mapcar #'car (epg-context-result-for context 'encrypted-to))) (if (or beg end) - (setq string (substring string (or beg 0) end))) + (setq string (substring string + (or beg 0) + (and end (min end (length string)))))) (save-excursion ;; If visiting, bind off buffer-file-name so that ;; file-locking will not ask whether we should commit 104c5e3d57705cd4bd291b61d7f165def602ab5c Author: Philipp Stephani Date: Mon Apr 12 09:20:51 2021 +0200 * lib-src/seccomp-filter.c: Add missing headers. diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c index ed362bc18d..fc3c3a0c07 100644 --- a/lib-src/seccomp-filter.c +++ b/lib-src/seccomp-filter.c @@ -51,6 +51,8 @@ variants of those files that can be used to sandbox Emacs before #include #include #include +#include +#include #include #include #include commit 17d20bb3cbb233ed0d94c3f1f9f3db768f526223 Author: Philipp Stephani Date: Mon Apr 12 09:15:59 2021 +0200 Generate Seccomp filters only if we have the necessary constants. If we're missing SECCOMP_SET_MODE_FILTER, the seccomp-filter build fails. Reuse the existing HAVE_SECCOMP configuration variable, which checks for these macros. * configure.ac (HAVE_SECCOMP): Substitute in Makefile.in. * lib-src/Makefile.in (HAVE_SECCOMP): New variable. (SECCOMP_FILTER): Define only if HAVE_SECCOMP. diff --git a/configure.ac b/configure.ac index 169ffc5534..d3647bdc2a 100644 --- a/configure.ac +++ b/configure.ac @@ -4188,6 +4188,7 @@ AC_CHECK_HEADERS( [[ #include ]])]) +AC_SUBST([HAVE_SECCOMP]) EMACS_CHECK_MODULES([LIBSECCOMP], [libseccomp >= 2.4.0]) AC_SUBST([HAVE_LIBSECCOMP]) diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 091f4fb019..923d0cf5e7 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -189,11 +189,13 @@ LIB_WSOCK32=@LIB_WSOCK32@ ## Extra libraries for etags LIBS_ETAGS = $(LIB_CLOCK_GETTIME) $(LIB_GETRANDOM) +HAVE_SECCOMP=@HAVE_SECCOMP@ HAVE_LIBSECCOMP=@HAVE_LIBSECCOMP@ LIBSECCOMP_LIBS=@LIBSECCOMP_LIBS@ LIBSECCOMP_CFLAGS=@LIBSECCOMP_CFLAGS@ # Currently, we can only generate seccomp filter files for x86-64. +ifeq ($(HAVE_SECCOMP),yes) ifeq ($(HAVE_LIBSECCOMP),yes) ifeq ($(shell uname -m),x86_64) # We require SECCOMP_RET_KILL_PROCESS, which is only available in @@ -205,6 +207,7 @@ SECCOMP_FILTER=1 endif endif endif +endif ifeq ($(SECCOMP_FILTER),1) DONT_INSTALL += seccomp-filter$(EXEEXT) commit c45bfd3c4abbfa585c9199f4866b6b8046945117 Author: Stefan Monnier Date: Sun Apr 11 23:47:14 2021 -0400 * lisp/**/*.el: Avoid positional args to `define-minor-mode` Back in Emacs-21.1, `define-minor-mode` grew keywords arguments to replace its old positional arguments. Let's make sure we don't use the old-style any more. * lisp/org/ox-beamer.el (org-beamer-mode-map): Move initialization into declaration. (org-beamer-mode): * lisp/textmodes/tildify.el (tildify-mode): * lisp/textmodes/sgml-mode.el (html-autoview-mode): * lisp/textmodes/rst.el (rst-minor-mode): * lisp/textmodes/remember.el (remember-notes-mode): * lisp/textmodes/ispell.el (ispell-minor-mode): * lisp/tar-mode.el (tar-subfile-mode): * lisp/strokes.el (strokes-mode): * lisp/so-long.el (so-long-minor-mode): * lisp/shell.el (shell-dirtrack-mode): * lisp/scroll-all.el (scroll-all-mode): * lisp/ruler-mode.el (ruler-mode): * lisp/rect.el (rectangle-mark-mode): * lisp/progmodes/sh-script.el (sh-electric-here-document-mode): * lisp/outline.el (outline-minor-mode): * lisp/org/org.el (org-cdlatex-mode): * lisp/org/org-table.el (org-table-header-line-mode) (org-table-follow-field-mode, orgtbl-mode): * lisp/org/org-src.el (org-src-mode): * lisp/org/org-list.el (org-list-checkbox-radio-mode): * lisp/org/org-indent.el (org-indent-mode): * lisp/org/org-capture.el (org-capture-mode): * lisp/obsolete/pc-select.el (pc-selection-mode): * lisp/obsolete/iswitchb.el (iswitchb-mode): * lisp/net/rcirc.el (rcirc-omit-mode, rcirc-multiline-minor-mode) (rcirc-track-minor-mode): * lisp/net/goto-addr.el (goto-address-mode, goto-address-prog-mode): * lisp/image-mode.el (image-minor-mode): * lisp/ibuf-ext.el (ibuffer-auto-mode): * lisp/gnus/gnus-cite.el (gnus-message-citation-mode): * lisp/font-core.el (font-lock-mode): * lisp/erc/erc.el (define-erc-module): * lisp/erc/erc-track.el (erc-track-minor-mode): * lisp/erc/erc-fill.el (erc-fill-mode): * lisp/epa-mail.el (epa-mail-mode): * lisp/emacs-lisp/checkdoc.el (checkdoc-minor-mode): * lisp/dirtrack.el (dirtrack-mode, dirtrack-debug-mode): * lisp/dired-aux.el (dired-isearch-filenames-mode): * lisp/cedet/semantic/idle.el (semantic-idle-scheduler-mode): * lisp/cedet/semantic/decorate/mode.el (semantic-decoration-mode): * lisp/autoarg.el (autoarg-mode, autoarg-kp-mode): * lisp/vc/pcvs.el (cvs-minor-mode): Avoid old-style positional args to `define-minor-mode`. diff --git a/lisp/autoarg.el b/lisp/autoarg.el index c2cb0c7051..7c2c6f1030 100644 --- a/lisp/autoarg.el +++ b/lisp/autoarg.el @@ -107,7 +107,7 @@ then invokes the normal binding of \\[autoarg-terminate]. `C-u \\[autoarg-terminate]' invokes the normal binding of \\[autoarg-terminate] four times. \\{autoarg-mode-map}" - nil " Aarg" autoarg-mode-map :global t :group 'keyboard) + :lighter" Aarg" :global t :group 'keyboard) ;;;###autoload (define-minor-mode autoarg-kp-mode @@ -118,7 +118,7 @@ This is similar to `autoarg-mode' but rebinds the keypad keys `kp-1' etc. to supply digit arguments. \\{autoarg-kp-mode-map}" - nil " Aakp" autoarg-kp-mode-map :global t :group 'keyboard + :lighter " Aakp" :global t :group 'keyboard (if autoarg-kp-mode (dotimes (i 10) (let ((sym (intern (format "kp-%d" i)))) diff --git a/lisp/cedet/semantic/decorate/mode.el b/lisp/cedet/semantic/decorate/mode.el index 7895015919..c6bf15205f 100644 --- a/lisp/cedet/semantic/decorate/mode.el +++ b/lisp/cedet/semantic/decorate/mode.el @@ -254,7 +254,7 @@ available and the current buffer was set up for parsing. Return non-nil if the minor mode is enabled." ;; ;;\\{semantic-decoration-map}" - nil nil nil + :lighter nil (if semantic-decoration-mode (if (not (and (featurep 'semantic) (semantic-active-p))) (progn diff --git a/lisp/cedet/semantic/idle.el b/lisp/cedet/semantic/idle.el index 420a457b0e..b883573a30 100644 --- a/lisp/cedet/semantic/idle.el +++ b/lisp/cedet/semantic/idle.el @@ -171,7 +171,8 @@ date, and reparses while the user is idle (not typing.) The minor mode can be turned on only if semantic feature is available and the current buffer was set up for parsing. Return -non-nil if the minor mode is enabled." nil nil nil +non-nil if the minor mode is enabled." + :lighter nil (if semantic-idle-scheduler-mode (if (not (and (featurep 'semantic) (semantic-active-p))) (progn diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index d5f4910876..8fe612fa0b 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -2980,7 +2980,7 @@ a file name. Otherwise, it searches the whole buffer without restrictions." When on, Isearch skips matches outside file names using the predicate `dired-isearch-filter-filenames' that matches only at file names. When off, it uses the original predicate." - nil nil nil + :lighter nil (if dired-isearch-filenames-mode (add-function :before-while (local 'isearch-filter-predicate) #'dired-isearch-filter-filenames diff --git a/lisp/dirtrack.el b/lisp/dirtrack.el index 7f76ef6653..be8db75c96 100644 --- a/lisp/dirtrack.el +++ b/lisp/dirtrack.el @@ -184,7 +184,7 @@ working directory at all times, and that you set the variable This is an alternative to `shell-dirtrack-mode', which works by tracking `cd' and similar commands which change the shell working directory." - nil nil nil + :lighter nil (if dirtrack-mode (add-hook 'comint-preoutput-filter-functions 'dirtrack nil t) (remove-hook 'comint-preoutput-filter-functions 'dirtrack t))) @@ -192,7 +192,7 @@ directory." (define-minor-mode dirtrack-debug-mode "Toggle Dirtrack debugging." - nil nil nil + :lighter nil (if dirtrack-debug-mode (display-buffer (get-buffer-create dirtrack-debug-buffer)))) diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 96b16f7ed4..00cc7777e1 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -1242,7 +1242,7 @@ bound to \\\\[checkdoc-eval-defun] and `checkdoc-eval-c checking of documentation strings. \\{checkdoc-minor-mode-map}" - nil checkdoc-minor-mode-string nil + :lighter checkdoc-minor-mode-string :group 'checkdoc) ;;; Subst utils diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el index 59ada5ec35..df864464b7 100644 --- a/lisp/emacs-lisp/macroexp.el +++ b/lisp/emacs-lisp/macroexp.el @@ -394,7 +394,8 @@ Assumes the caller has bound `macroexpand-all-environment'." ;; Record which arguments expect functions, so we can warn when those ;; are accidentally quoted with ' rather than with #' -(dolist (f '(funcall apply mapcar mapatoms mapconcat mapc cl-mapcar maphash)) +(dolist (f '( funcall apply mapcar mapatoms mapconcat mapc cl-mapcar maphash + map-char-table map-keymap map-keymap-internal)) (put f 'funarg-positions '(1))) (dolist (f '( add-hook remove-hook advice-remove advice--remove-function defalias fset global-set-key run-after-idle-timeout diff --git a/lisp/epa-mail.el b/lisp/epa-mail.el index 7e100569b0..7eac1f8998 100644 --- a/lisp/epa-mail.el +++ b/lisp/epa-mail.el @@ -59,7 +59,7 @@ Otherwise, signal an error." ;;;###autoload (define-minor-mode epa-mail-mode "A minor-mode for composing encrypted/clearsigned mails." - nil " epa-mail" epa-mail-mode-map) + :lighter " epa-mail") ;;; Utilities diff --git a/lisp/erc/erc-fill.el b/lisp/erc/erc-fill.el index 0312d221ec..41256682c0 100644 --- a/lisp/erc/erc-fill.el +++ b/lisp/erc/erc-fill.el @@ -46,7 +46,6 @@ the mode if ARG is omitted or nil. ERC fill mode is a global minor mode. When enabled, messages in the channel buffers are filled." - nil nil nil :global t (if erc-fill-mode (erc-fill-enable) diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index 9985b6a02f..2364d45d6f 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el @@ -464,9 +464,6 @@ ERC Track minor mode is a global minor mode. It exists for the sole purpose of providing the C-c C-SPC and C-c C-@ keybindings. Make sure that you have enabled the track module, otherwise the keybindings will not do anything useful." - :init-value nil - :lighter "" - :keymap erc-track-minor-mode-map :global t) (defun erc-track-minor-mode-maybe (&optional buffer) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index f0144de844..e20aa8057d 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1289,7 +1289,6 @@ With a prefix argument ARG, enable %s if ARG is positive, and disable it otherwise. If called from Lisp, enable the mode if ARG is omitted or nil. %s" name name doc) - nil nil nil ;; FIXME: We don't know if this group exists, so this `:group' may ;; actually just silence a valid warning about the fact that the var ;; is not associated with any group. diff --git a/lisp/font-core.el b/lisp/font-core.el index 4b69542497..db06a60766 100644 --- a/lisp/font-core.el +++ b/lisp/font-core.el @@ -126,7 +126,6 @@ buffer local value for `font-lock-defaults', via its mode hook. The above is the default behavior of `font-lock-mode'; you may specify your own function which is called when `font-lock-mode' is toggled via `font-lock-function'." - nil nil nil :after-hook (font-lock-initial-fontify) ;; Don't turn on Font Lock mode if we don't have a display (we're running a ;; batch job) or if the buffer is invisible (the name starts with a space). diff --git a/lisp/gnus/gnus-cite.el b/lisp/gnus/gnus-cite.el index 4249b50b9f..34947cece8 100644 --- a/lisp/gnus/gnus-cite.el +++ b/lisp/gnus/gnus-cite.el @@ -1134,9 +1134,7 @@ Returns nil if there is no such line before LIMIT, t otherwise." (define-minor-mode gnus-message-citation-mode "Minor mode providing more font-lock support for nested citations. When enabled, it automatically turns on `font-lock-mode'." - nil ;; init-value - "" ;; lighter - nil ;; keymap + :lighter "" (when (derived-mode-p 'message-mode) ;; FIXME: Use font-lock-add-keywords! (let ((defaults (car font-lock-defaults)) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 48f9e8a990..1dc8acbe1f 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -402,7 +402,7 @@ format. See `ibuffer-update-saved-filters-format' and ;;;###autoload (define-minor-mode ibuffer-auto-mode "Toggle use of Ibuffer's auto-update facility (Ibuffer Auto mode)." - nil nil nil + :lighter nil (unless (derived-mode-p 'ibuffer-mode) (error "This buffer is not in Ibuffer mode")) (cond (ibuffer-auto-mode diff --git a/lisp/image-mode.el b/lisp/image-mode.el index f4ff35f9c4..69ef7015cc 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -713,8 +713,7 @@ Key bindings: Image minor mode provides the key \\\\[image-toggle-display], to switch back to `image-mode' and display an image file as the actual image." - nil (:eval (if image-type (format " Image[%s]" image-type) " Image")) - image-minor-mode-map + :lighter (:eval (if image-type (format " Image[%s]" image-type) " Image")) :group 'image :version "22.1" (if image-minor-mode diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index af12f6970a..8992ef736a 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el @@ -263,9 +263,7 @@ Also fontifies the buffer appropriately (see `goto-address-fontify-p' and ;;;###autoload (define-minor-mode goto-address-mode "Minor mode to buttonize URLs and e-mail addresses in the current buffer." - nil - "" - nil + :lighter "" (if goto-address-mode (jit-lock-register #'goto-address-fontify-region) (jit-lock-unregister #'goto-address-fontify-region) @@ -285,9 +283,7 @@ Also fontifies the buffer appropriately (see `goto-address-fontify-p' and ;;;###autoload (define-minor-mode goto-address-prog-mode "Like `goto-address-mode', but only for comments and strings." - nil - "" - nil + :lighter "" (if goto-address-prog-mode (jit-lock-register #'goto-address-fontify-region) (jit-lock-unregister #'goto-address-fontify-region) diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 938fadfed7..7bb8ca671c 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -196,7 +196,7 @@ If nil, no maximum is applied." Uninteresting lines are those whose responses are listed in `rcirc-omit-responses'." - nil " Omit" nil + :lighter " Omit" (if rcirc-omit-mode (progn (add-to-invisibility-spec '(rcirc-omit . nil)) @@ -1359,9 +1359,7 @@ Create the buffer if it doesn't exist." (define-minor-mode rcirc-multiline-minor-mode "Minor mode for editing multiple lines in rcirc." - :init-value nil :lighter " rcirc-mline" - :keymap rcirc-multiline-minor-mode-map :global nil (setq fill-column rcirc-max-message-length)) @@ -1863,9 +1861,6 @@ This function does not alter the INPUT string." ;;;###autoload (define-minor-mode rcirc-track-minor-mode "Global minor mode for tracking activity in rcirc buffers." - :init-value nil - :lighter "" - :keymap rcirc-track-minor-mode-map :global t (or global-mode-string (setq global-mode-string '(""))) ;; toggle the mode-line channel indicator diff --git a/lisp/obsolete/iswitchb.el b/lisp/obsolete/iswitchb.el index 7ffee762eb..a630baf354 100644 --- a/lisp/obsolete/iswitchb.el +++ b/lisp/obsolete/iswitchb.el @@ -1336,7 +1336,7 @@ See the variable `iswitchb-case' for details." Iswitchb mode is a global minor mode that enables switching between buffers using substrings. See `iswitchb' for details." - nil nil iswitchb-global-map :global t + :keymap iswitchb-global-map :global t (if iswitchb-mode (add-hook 'minibuffer-setup-hook #'iswitchb-minibuffer-setup) (remove-hook 'minibuffer-setup-hook #'iswitchb-minibuffer-setup))) diff --git a/lisp/obsolete/pc-select.el b/lisp/obsolete/pc-select.el index 59828759e6..f999f50797 100644 --- a/lisp/obsolete/pc-select.el +++ b/lisp/obsolete/pc-select.el @@ -314,8 +314,6 @@ but before calling PC Selection mode): C-BACKSPACE backward-kill-word M-BACKSPACE undo" ;; FIXME: bring pc-bindings-mode here ? - nil nil nil - :global t (if pc-selection-mode diff --git a/lisp/org/org-capture.el b/lisp/org/org-capture.el index f40f2b335e..7ae8fae3aa 100644 --- a/lisp/org/org-capture.el +++ b/lisp/org/org-capture.el @@ -521,7 +521,7 @@ for a capture buffer.") "Minor mode for special key bindings in a capture buffer. Turning on this mode runs the normal hook `org-capture-mode-hook'." - nil " Cap" org-capture-mode-map + :lighter " Cap" (setq-local header-line-format (substitute-command-keys diff --git a/lisp/org/org-indent.el b/lisp/org/org-indent.el index c6bf416564..3475cadc42 100644 --- a/lisp/org/org-indent.el +++ b/lisp/org/org-indent.el @@ -167,7 +167,7 @@ properties, after each buffer modification, on the modified zone. The process is synchronous. Though, initial indentation of buffer, which can take a few seconds on large buffers, is done during idle time." - nil " Ind" nil + :lighter " Ind" (cond (org-indent-mode ;; mode was turned on. diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el index 39122e7ce4..f97164ee33 100644 --- a/lisp/org/org-list.el +++ b/lisp/org/org-list.el @@ -2304,7 +2304,7 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is ;;;###autoload (define-minor-mode org-list-checkbox-radio-mode "When turned on, use list checkboxes as radio buttons." - nil " CheckBoxRadio" nil + :lighter " CheckBoxRadio" (unless (eq major-mode 'org-mode) (user-error "Cannot turn this mode outside org-mode buffers"))) diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el index 20acee4e66..cabedecb68 100644 --- a/lisp/org/org-src.el +++ b/lisp/org/org-src.el @@ -682,7 +682,7 @@ This minor mode is turned on in two situations: \\{org-src-mode-map} See also `org-src-mode-hook'." - nil " OrgSrc" nil + :lighter " OrgSrc" (when org-edit-src-persistent-message (setq header-line-format (substitute-command-keys diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el index 1248efabc1..0e93fb271f 100644 --- a/lisp/org/org-table.el +++ b/lisp/org/org-table.el @@ -495,7 +495,7 @@ This may be useful when columns have been shrunk." ;;;###autoload (define-minor-mode org-table-header-line-mode "Display the first row of the table at point in the header line." - nil " TblHeader" nil + :lighter " TblHeader" (unless (eq major-mode 'org-mode) (user-error "Cannot turn org table header mode outside org-mode buffers")) (if org-table-header-line-mode @@ -1976,7 +1976,7 @@ lines." When this mode is active, the field editor window will always show the current field. The mode exits automatically when the cursor leaves the table (but see `org-table-exit-follow-field-mode-when-leaving-table')." - nil " TblFollow" nil + :lighter " TblFollow" (if org-table-follow-field-mode (add-hook 'post-command-hook 'org-table-follow-fields-with-editor 'append 'local) @@ -5149,7 +5149,7 @@ When LOCAL is non-nil, show references for the table at point." ;;;###autoload (define-minor-mode orgtbl-mode "The Org mode table editor as a minor mode for use in other modes." - :lighter " OrgTbl" :keymap orgtbl-mode-map + :lighter " OrgTbl" (org-load-modules-maybe) (cond ((derived-mode-p 'org-mode) diff --git a/lisp/org/org.el b/lisp/org/org.el index cebe1735be..f560c65dc4 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -15584,7 +15584,7 @@ When a buffer is unmodified, it is just killed. When modified, it is saved This mode supports entering LaTeX environment and math in LaTeX fragments in Org mode. \\{org-cdlatex-mode-map}" - nil " OCDL" nil + :lighter " OCDL" (when org-cdlatex-mode (require 'cdlatex) (run-hooks 'cdlatex-mode-hook) diff --git a/lisp/org/ox-beamer.el b/lisp/org/ox-beamer.el index 1a1732b683..6ed95e84d6 100644 --- a/lisp/org/ox-beamer.el +++ b/lisp/org/ox-beamer.el @@ -895,14 +895,16 @@ holding export options." ;;; Minor Mode -(defvar org-beamer-mode-map (make-sparse-keymap) +(defvar org-beamer-mode-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-c\C-b" 'org-beamer-select-environment) + map) "The keymap for `org-beamer-mode'.") -(define-key org-beamer-mode-map "\C-c\C-b" 'org-beamer-select-environment) ;;;###autoload (define-minor-mode org-beamer-mode "Support for editing Beamer oriented Org mode files." - nil " Bm" 'org-beamer-mode-map) + :lighter " Bm") (when (fboundp 'font-lock-add-keywords) (font-lock-add-keywords diff --git a/lisp/outline.el b/lisp/outline.el index 79029a6e5e..bce9c6b9e4 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -374,8 +374,9 @@ faces to major mode's faces." "Toggle Outline minor mode. See the command `outline-mode' for more information on this mode." - nil " Outl" (list (cons [menu-bar] outline-minor-mode-menu-bar-map) - (cons outline-minor-mode-prefix outline-mode-prefix-map)) + :lighter " Outl" + :keymap (list (cons [menu-bar] outline-minor-mode-menu-bar-map) + (cons outline-minor-mode-prefix outline-mode-prefix-map)) (if outline-minor-mode (progn (when (or outline-minor-mode-cycle outline-minor-mode-highlight) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index ba59f9c661..c6bd32a4a4 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -2967,7 +2967,7 @@ The document is bounded by `sh-here-document-word'." (define-minor-mode sh-electric-here-document-mode "Make << insert a here document skeleton." - nil nil nil + :lighter nil (if sh-electric-here-document-mode (add-hook 'post-self-insert-hook #'sh--maybe-here-document nil t) (remove-hook 'post-self-insert-hook #'sh--maybe-here-document t))) diff --git a/lisp/rect.el b/lisp/rect.el index cb941b4600..504be41b67 100644 --- a/lisp/rect.el +++ b/lisp/rect.el @@ -652,7 +652,7 @@ with a prefix argument, prompt for START-AT and FORMAT." "Toggle the region as rectangular. Activates the region if needed. Only lasts until the region is deactivated." - nil nil nil + :lighter nil (rectangle--reset-crutches) (when rectangle-mark-mode (add-hook 'deactivate-mark-hook diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el index 11226fda02..a0d4f6e96c 100644 --- a/lisp/ruler-mode.el +++ b/lisp/ruler-mode.el @@ -568,8 +568,6 @@ format first." ;;;###autoload (define-minor-mode ruler-mode "Toggle display of ruler in header line (Ruler mode)." - nil nil - ruler-mode-map :group 'ruler-mode :variable (ruler-mode . (lambda (enable) diff --git a/lisp/scroll-all.el b/lisp/scroll-all.el index 8ba0cc9e03..415244f9e9 100644 --- a/lisp/scroll-all.el +++ b/lisp/scroll-all.el @@ -108,7 +108,7 @@ ARG is like in `end-of-buffer'." When Scroll-All mode is enabled, scrolling commands invoked in one window apply to all visible windows in the same frame." - nil " *SL*" nil + :lighter " *SL*" :global t :group 'windows (if scroll-all-mode diff --git a/lisp/shell.el b/lisp/shell.el index cd99b00877..3098d3a14d 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -980,7 +980,7 @@ Environment variables are expanded, see function `substitute-in-file-name'." The `dirtrack' package provides an alternative implementation of this feature; see the function `dirtrack-mode'." - nil nil nil + :lighter nil (setq list-buffers-directory (if shell-dirtrack-mode default-directory)) (if shell-dirtrack-mode (add-hook 'comint-input-filter-functions #'shell-directory-tracker nil t) diff --git a/lisp/so-long.el b/lisp/so-long.el index f44d41dc5e..f916b61b60 100644 --- a/lisp/so-long.el +++ b/lisp/so-long.el @@ -1185,7 +1185,7 @@ current buffer, and buffer-local values are assigned to variables in accordance with `so-long-variable-overrides'. This minor mode is a standard `so-long-action' option." - nil nil nil + :lighter nil (if so-long-minor-mode ;; We are enabling the mode. (progn ;; Housekeeping. `so-long-minor-mode' might be invoked directly rather diff --git a/lisp/strokes.el b/lisp/strokes.el index 4b682e99fe..4a018ff199 100644 --- a/lisp/strokes.el +++ b/lisp/strokes.el @@ -1393,7 +1393,7 @@ Encode/decode your strokes with \\[strokes-encode-buffer], \\[strokes-decode-buffer]. \\{strokes-mode-map}" - nil strokes-lighter strokes-mode-map :global t + :ligher strokes-lighter :global t (cond ((not (display-mouse-p)) (error "Can't use Strokes without a mouse")) (strokes-mode ; turn on strokes diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index fa9b47556f..d9b2d42193 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el @@ -751,7 +751,7 @@ into the tar-file buffer that it came from. The changes will actually appear on disk when you save the tar-file's buffer." ;; Don't do this, because it is redundant and wastes mode line space. ;; :lighter " TarFile" - nil nil nil + :lighter nil (or (and (boundp 'tar-superior-buffer) tar-superior-buffer) (error "This buffer is not an element of a tar file")) (cond (tar-subfile-mode diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index eb521134dc..932308ee59 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -3744,7 +3744,7 @@ SPC. For spell-checking \"on the fly\", not just after typing SPC or RET, use `flyspell-mode'." - nil " Spell" ispell-minor-keymap) + :lighter " Spell" :keymap ispell-minor-keymap) (defun ispell-minor-check () "Check previous word, then continue with the normal binding of this key. diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el index cd76bf80f1..8a0436afc6 100644 --- a/lisp/textmodes/remember.el +++ b/lisp/textmodes/remember.el @@ -607,7 +607,7 @@ This sets `buffer-save-without-query' so that `save-some-buffers' will save the notes buffer without asking. \\{remember-notes-mode-map}" - nil nil nil + :lighter nil (cond (remember-notes-mode (add-hook 'kill-buffer-query-functions diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el index 56cca84004..1471be0ecd 100644 --- a/lisp/textmodes/rst.el +++ b/lisp/textmodes/rst.el @@ -1408,13 +1408,11 @@ highlighting. When ReST minor mode is enabled, the ReST mode keybindings are installed on top of the major mode bindings. Use this for modes derived from Text mode, like Mail mode." - ;; The initial value. - nil - ;; The indicator for the mode line. - " ReST" - ;; The minor mode bindings. - rst-mode-map - :group 'rst) + ;; The indicator for the mode line. + :lighter " ReST" + ;; The minor mode bindings. + :keymap rst-mode-map + :group 'rst) ;; FIXME: can I somehow install these too? ;; :abbrev-table rst-mode-abbrev-table diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 6958ab8f65..67f731917e 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -2440,7 +2440,7 @@ The third `match-string' will be the used in the menu.") HTML Autoview mode is a buffer-local minor mode for use with `html-mode'. If enabled, saving the file automatically runs `browse-url-of-buffer' to view it." - nil nil nil + :lighter nil (if html-autoview-mode (add-hook 'after-save-hook #'browse-url-of-buffer nil t) (remove-hook 'after-save-hook #'browse-url-of-buffer t))) diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index 069c8e3f44..163978b431 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -486,7 +486,7 @@ that space character is replaced by a hard space specified by When `tildify-mode' is enabled, if `tildify-string-alist' specifies a hard space representation for current major mode, the `tildify-space-string' buffer-local variable will be set to the representation." - nil " ~" nil + :lighter " ~" (when tildify-mode (let ((space (with-suppressed-warnings ((obsolete tildify--pick-alist-entry)) diff --git a/lisp/vc/pcvs.el b/lisp/vc/pcvs.el index 6e039cc625..42f531e4f7 100644 --- a/lisp/vc/pcvs.el +++ b/lisp/vc/pcvs.el @@ -331,7 +331,7 @@ the primary since reading the primary can deactivate it." "This mode is used for buffers related to a main *cvs* buffer. All the `cvs-mode' buffer operations are simply rebound under the \\[cvs-mode-map] prefix." - nil " CVS" + :lighter " CVS" :group 'pcl-cvs) (put 'cvs-minor-mode 'permanent-local t) commit ccfd6a975e377db6f0ebb9ad6eb0798cff169ce9 Author: Stefan Monnier Date: Sun Apr 11 22:55:18 2021 -0400 * lisp/gnus/message.el: Give non-nil defaults for function vars Also prefer #' to quote functions. (message-send-rename-function, message-reply-to-function) (message-wide-reply-to-function, message-followup-to-function): Use a non-nil default value so it can be used with `add-function`. (message-do-send-housekeeping): Tweak accordingly. (message-get-reply-headers): Simplify by η-reduction. diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index fad4ef3dcf..f3b830cf84 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -120,12 +120,13 @@ :group 'message-buffers :type 'integer) -(defcustom message-send-rename-function nil +(defcustom message-send-rename-function #'message-default-send-rename-function "Function called to rename the buffer after sending it." :group 'message-buffers - :type '(choice function (const nil))) + :version "28.1" + :type 'function) -(defcustom message-fcc-handler-function 'message-output +(defcustom message-fcc-handler-function #'message-output "A function called to save outgoing articles. This function will be called with the name of the file to store the article in. The default function is `message-output' which saves in Unix @@ -418,7 +419,7 @@ you can explicitly override this setting by calling :type 'string :group 'message-various) -(defcustom message-cross-post-note-function 'message-cross-post-insert-note +(defcustom message-cross-post-note-function #'message-cross-post-insert-note "Function to use to insert note about Crosspost or Followup-To. The function will be called with four arguments. The function should not only insert a note, but also ensure old notes are deleted. See the documentation @@ -756,7 +757,7 @@ See also `send-mail-function'." :link '(custom-manual "(message)Mail Variables") :group 'message-mail) -(defcustom message-send-news-function 'message-send-news +(defcustom message-send-news-function #'message-send-news "Function to call to send the current buffer as news. The headers should be delimited by a line whose contents match the variable `mail-header-separator'." @@ -765,29 +766,32 @@ variable `mail-header-separator'." :link '(custom-manual "(message)News Variables") :type 'function) -(defcustom message-reply-to-function nil +(defcustom message-reply-to-function #'ignore "If non-nil, function that should return a list of headers. This function should pick out addresses from the To, Cc, and From headers and respond with new To and Cc headers." :group 'message-interface :link '(custom-manual "(message)Reply") - :type '(choice function (const nil))) + :version "28.1" + :type 'function) -(defcustom message-wide-reply-to-function nil +(defcustom message-wide-reply-to-function #'ignore "If non-nil, function that should return a list of headers. This function should pick out addresses from the To, Cc, and From headers and respond with new To and Cc headers." :group 'message-interface :link '(custom-manual "(message)Wide Reply") - :type '(choice function (const nil))) + :version "28.1" + :type 'function) -(defcustom message-followup-to-function nil +(defcustom message-followup-to-function #'ignore "If non-nil, function that should return a list of headers. This function should pick out addresses from the To, Cc, and From headers and respond with new To and Cc headers." :group 'message-interface :link '(custom-manual "(message)Followup") - :type '(choice function (const nil))) + :version "28.1" + :type 'function) (defcustom message-extra-wide-headers nil "If non-nil, a list of additional address headers. @@ -1021,7 +1025,7 @@ the signature is inserted." :version "22.1" :group 'message-various) -(defcustom message-citation-line-function 'message-insert-citation-line +(defcustom message-citation-line-function #'message-insert-citation-line "Function called to insert the \"Whomever writes:\" line. Predefined functions include `message-insert-citation-line' and @@ -1103,7 +1107,7 @@ Used by `message-yank-original' via `message-yank-cite'." :link '(custom-manual "(message)Insertion Variables") :type 'integer) -(defcustom message-cite-function 'message-cite-original-without-signature +(defcustom message-cite-function #'message-cite-original-without-signature "Function for citing an original message. Predefined functions include `message-cite-original' and `message-cite-original-without-signature'. @@ -1116,7 +1120,7 @@ Note that these functions use `mail-citation-hook' if that is non-nil." :version "22.3" ;; Gnus 5.10.12 (changed default) :group 'message-insertion) -(defcustom message-indent-citation-function 'message-indent-citation +(defcustom message-indent-citation-function #'message-indent-citation "Function for modifying a citation just inserted in the mail buffer. This can also be a list of functions. Each function can find the citation between (point) and (mark t). And each function should leave @@ -2847,79 +2851,79 @@ Consider adding this function to `message-header-setup-hook'" (unless message-mode-map (setq message-mode-map (make-keymap)) (set-keymap-parent message-mode-map text-mode-map) - (define-key message-mode-map "\C-c?" 'describe-mode) - - (define-key message-mode-map "\C-c\C-f\C-t" 'message-goto-to) - (define-key message-mode-map "\C-c\C-f\C-o" 'message-goto-from) - (define-key message-mode-map "\C-c\C-f\C-b" 'message-goto-bcc) - (define-key message-mode-map "\C-c\C-f\C-w" 'message-goto-fcc) - (define-key message-mode-map "\C-c\C-f\C-c" 'message-goto-cc) - (define-key message-mode-map "\C-c\C-f\C-s" 'message-goto-subject) - (define-key message-mode-map "\C-c\C-f\C-r" 'message-goto-reply-to) - (define-key message-mode-map "\C-c\C-f\C-n" 'message-goto-newsgroups) - (define-key message-mode-map "\C-c\C-f\C-d" 'message-goto-distribution) - (define-key message-mode-map "\C-c\C-f\C-f" 'message-goto-followup-to) - (define-key message-mode-map "\C-c\C-f\C-m" 'message-goto-mail-followup-to) - (define-key message-mode-map "\C-c\C-f\C-k" 'message-goto-keywords) - (define-key message-mode-map "\C-c\C-f\C-u" 'message-goto-summary) + (define-key message-mode-map "\C-c?" #'describe-mode) + + (define-key message-mode-map "\C-c\C-f\C-t" #'message-goto-to) + (define-key message-mode-map "\C-c\C-f\C-o" #'message-goto-from) + (define-key message-mode-map "\C-c\C-f\C-b" #'message-goto-bcc) + (define-key message-mode-map "\C-c\C-f\C-w" #'message-goto-fcc) + (define-key message-mode-map "\C-c\C-f\C-c" #'message-goto-cc) + (define-key message-mode-map "\C-c\C-f\C-s" #'message-goto-subject) + (define-key message-mode-map "\C-c\C-f\C-r" #'message-goto-reply-to) + (define-key message-mode-map "\C-c\C-f\C-n" #'message-goto-newsgroups) + (define-key message-mode-map "\C-c\C-f\C-d" #'message-goto-distribution) + (define-key message-mode-map "\C-c\C-f\C-f" #'message-goto-followup-to) + (define-key message-mode-map "\C-c\C-f\C-m" #'message-goto-mail-followup-to) + (define-key message-mode-map "\C-c\C-f\C-k" #'message-goto-keywords) + (define-key message-mode-map "\C-c\C-f\C-u" #'message-goto-summary) (define-key message-mode-map "\C-c\C-f\C-i" - 'message-insert-or-toggle-importance) + #'message-insert-or-toggle-importance) (define-key message-mode-map "\C-c\C-f\C-a" - 'message-generate-unsubscribed-mail-followup-to) + #'message-generate-unsubscribed-mail-followup-to) ;; modify headers (and insert notes in body) - (define-key message-mode-map "\C-c\C-fs" 'message-change-subject) + (define-key message-mode-map "\C-c\C-fs" #'message-change-subject) ;; - (define-key message-mode-map "\C-c\C-fx" 'message-cross-post-followup-to) + (define-key message-mode-map "\C-c\C-fx" #'message-cross-post-followup-to) ;; prefix+message-cross-post-followup-to = same w/o cross-post - (define-key message-mode-map "\C-c\C-ft" 'message-reduce-to-to-cc) - (define-key message-mode-map "\C-c\C-fa" 'message-add-archive-header) + (define-key message-mode-map "\C-c\C-ft" #'message-reduce-to-to-cc) + (define-key message-mode-map "\C-c\C-fa" #'message-add-archive-header) ;; mark inserted text - (define-key message-mode-map "\C-c\M-m" 'message-mark-inserted-region) - (define-key message-mode-map "\C-c\M-f" 'message-mark-insert-file) + (define-key message-mode-map "\C-c\M-m" #'message-mark-inserted-region) + (define-key message-mode-map "\C-c\M-f" #'message-mark-insert-file) - (define-key message-mode-map "\C-c\C-b" 'message-goto-body) - (define-key message-mode-map "\C-c\C-i" 'message-goto-signature) + (define-key message-mode-map "\C-c\C-b" #'message-goto-body) + (define-key message-mode-map "\C-c\C-i" #'message-goto-signature) - (define-key message-mode-map "\C-c\C-t" 'message-insert-to) - (define-key message-mode-map "\C-c\C-fw" 'message-insert-wide-reply) - (define-key message-mode-map "\C-c\C-n" 'message-insert-newsgroups) - (define-key message-mode-map "\C-c\C-l" 'message-to-list-only) - (define-key message-mode-map "\C-c\C-f\C-e" 'message-insert-expires) + (define-key message-mode-map "\C-c\C-t" #'message-insert-to) + (define-key message-mode-map "\C-c\C-fw" #'message-insert-wide-reply) + (define-key message-mode-map "\C-c\C-n" #'message-insert-newsgroups) + (define-key message-mode-map "\C-c\C-l" #'message-to-list-only) + (define-key message-mode-map "\C-c\C-f\C-e" #'message-insert-expires) - (define-key message-mode-map "\C-c\C-u" 'message-insert-or-toggle-importance) + (define-key message-mode-map "\C-c\C-u" #'message-insert-or-toggle-importance) (define-key message-mode-map "\C-c\M-n" - 'message-insert-disposition-notification-to) - - (define-key message-mode-map "\C-c\C-y" 'message-yank-original) - (define-key message-mode-map "\C-c\M-\C-y" 'message-yank-buffer) - (define-key message-mode-map "\C-c\C-q" 'message-fill-yanked-message) - (define-key message-mode-map "\C-c\C-w" 'message-insert-signature) - (define-key message-mode-map "\C-c\M-h" 'message-insert-headers) - (define-key message-mode-map "\C-c\C-r" 'message-caesar-buffer-body) - (define-key message-mode-map "\C-c\C-o" 'message-sort-headers) - (define-key message-mode-map "\C-c\M-r" 'message-rename-buffer) - - (define-key message-mode-map "\C-c\C-c" 'message-send-and-exit) - (define-key message-mode-map "\C-c\C-s" 'message-send) - (define-key message-mode-map "\C-c\C-k" 'message-kill-buffer) - (define-key message-mode-map "\C-c\C-d" 'message-dont-send) - (define-key message-mode-map "\C-c\n" 'gnus-delay-article) - - (define-key message-mode-map "\C-c\M-k" 'message-kill-address) - (define-key message-mode-map "\C-c\C-e" 'message-elide-region) - (define-key message-mode-map "\C-c\C-v" 'message-delete-not-region) - (define-key message-mode-map "\C-c\C-z" 'message-kill-to-signature) - (define-key message-mode-map "\M-\r" 'message-newline-and-reformat) - (define-key message-mode-map [remap split-line] 'message-split-line) - - (define-key message-mode-map "\C-c\C-a" 'mml-attach-file) - (define-key message-mode-map "\C-c\C-p" 'message-insert-screenshot) - - (define-key message-mode-map "\C-a" 'message-beginning-of-line) - (define-key message-mode-map "\t" 'message-tab) - - (define-key message-mode-map "\M-n" 'message-display-abbrev)) + #'message-insert-disposition-notification-to) + + (define-key message-mode-map "\C-c\C-y" #'message-yank-original) + (define-key message-mode-map "\C-c\M-\C-y" #'message-yank-buffer) + (define-key message-mode-map "\C-c\C-q" #'message-fill-yanked-message) + (define-key message-mode-map "\C-c\C-w" #'message-insert-signature) + (define-key message-mode-map "\C-c\M-h" #'message-insert-headers) + (define-key message-mode-map "\C-c\C-r" #'message-caesar-buffer-body) + (define-key message-mode-map "\C-c\C-o" #'message-sort-headers) + (define-key message-mode-map "\C-c\M-r" #'message-rename-buffer) + + (define-key message-mode-map "\C-c\C-c" #'message-send-and-exit) + (define-key message-mode-map "\C-c\C-s" #'message-send) + (define-key message-mode-map "\C-c\C-k" #'message-kill-buffer) + (define-key message-mode-map "\C-c\C-d" #'message-dont-send) + (define-key message-mode-map "\C-c\n" #'gnus-delay-article) + + (define-key message-mode-map "\C-c\M-k" #'message-kill-address) + (define-key message-mode-map "\C-c\C-e" #'message-elide-region) + (define-key message-mode-map "\C-c\C-v" #'message-delete-not-region) + (define-key message-mode-map "\C-c\C-z" #'message-kill-to-signature) + (define-key message-mode-map "\M-\r" #'message-newline-and-reformat) + (define-key message-mode-map [remap split-line] #'message-split-line) + + (define-key message-mode-map "\C-c\C-a" #'mml-attach-file) + (define-key message-mode-map "\C-c\C-p" #'message-insert-screenshot) + + (define-key message-mode-map "\C-a" #'message-beginning-of-line) + (define-key message-mode-map "\t" #'message-tab) + + (define-key message-mode-map "\M-n" #'message-display-abbrev)) (easy-menu-define message-mode-menu message-mode-map "Message Menu." @@ -3169,14 +3173,13 @@ Like `text-mode', but with these additional commands: ;; `electric-pair-mode', and C-M-* navigation by syntactically ;; excluding citations and other artifacts. ;; - (setq-local syntax-propertize-function 'message--syntax-propertize) + (setq-local syntax-propertize-function #'message--syntax-propertize) (setq-local parse-sexp-ignore-comments t) (setq-local message-encoded-mail-cache nil)) (defun message-setup-fill-variables () "Setup message fill variables." (setq-local fill-paragraph-function #'message-fill-paragraph) - (make-local-variable 'adaptive-fill-first-line-regexp) (let ((quote-prefix-regexp ;; User should change message-cite-prefix-regexp if ;; message-yank-prefix is set to an abnormal value. @@ -3287,7 +3290,7 @@ Like `text-mode', but with these additional commands: (push-mark) (message-position-on-field "Summary" "Subject")) -(define-obsolete-function-alias 'message-goto-body-1 'message-goto-body "27.1") +(define-obsolete-function-alias 'message-goto-body-1 #'message-goto-body "27.1") (defun message-goto-body (&optional interactive) "Move point to the beginning of the message body. Returns point." @@ -6662,9 +6665,8 @@ moved to the beginning " (not (buffer-modified-p buffer))) (kill-buffer buffer)))) ;; Rename the buffer. - (if message-send-rename-function - (funcall message-send-rename-function) - (message-default-send-rename-function)) + (funcall (or message-send-rename-function + #'message-default-send-rename-function)) ;; Push the current buffer onto the list. (when message-max-buffers (setq message-buffer-list @@ -6763,8 +6765,9 @@ are not included." (defun message-setup-1 (headers &optional yank-action actions return-action) (dolist (action actions) (condition-case nil + ;; FIXME: Use functions rather than expressions! (add-to-list 'message-send-actions - `(apply ',(car action) ',(cdr action))))) + `(apply #',(car action) ',(cdr action))))) (setq message-return-action return-action) (setq message-reply-buffer (if (and (consp yank-action) @@ -6903,7 +6906,7 @@ are not included." ;;;###autoload (defun message-mail (&optional to subject other-headers continue switch-function yank-action send-actions - return-action &rest ignored) + return-action &rest _) "Start editing a mail message to be sent. OTHER-HEADERS is an alist of header/value pairs. CONTINUE says whether to continue editing a message already being composed. SWITCH-FUNCTION @@ -7127,15 +7130,12 @@ want to get rid of this query permanently."))) ;; specific, and just Cc-in the rest. (setq follow-to (list (cons 'To - (mapconcat - (lambda (addr) - (cdr addr)) recipients ", ")))) + (mapconcat #'cdr recipients ", ")))) ;; Put the first recipient in the To header. (setq follow-to (list (cons 'To (cdr (pop recipients))))) ;; Put the rest of the recipients in Cc. (when recipients - (setq recipients (mapconcat - (lambda (addr) (cdr addr)) recipients ", ")) + (setq recipients (mapconcat #'cdr recipients ", ")) (if (string-match "^ +" recipients) (setq recipients (substring recipients (match-end 0)))) (push (cons 'Cc recipients) follow-to))))) @@ -7862,7 +7862,7 @@ is for the internal use." (interactive) (setq rmail-enable-mime-composing t) (setq rmail-insert-mime-forwarded-message-function - 'message-forward-rmail-make-body)) + #'message-forward-rmail-make-body)) ;;;###autoload (defun message-resend (address) commit a89da3f00840bf95d92f9959f62fd1a0f7d26566 Author: Stefan Monnier Date: Sun Apr 11 22:46:48 2021 -0400 * lisp/eshell/esh-util.el: Require `seq` Also remove redundant `:group` args and tweak comment diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index a48f62654d..30104816f0 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el @@ -23,6 +23,7 @@ ;;; Code: +(require 'seq) (eval-when-compile (require 'cl-lib)) (defgroup eshell-util nil @@ -37,25 +38,21 @@ If nil, t will be represented only in the exit code of the function, and not printed as a string. This causes Lisp functions to behave similarly to external commands, as far as successful result output." - :type 'boolean - :group 'eshell-util) + :type 'boolean) (defcustom eshell-group-file "/etc/group" "If non-nil, the name of the group file on your system." - :type '(choice (const :tag "No group file" nil) file) - :group 'eshell-util) + :type '(choice (const :tag "No group file" nil) file)) (defcustom eshell-passwd-file "/etc/passwd" "If non-nil, the name of the passwd file on your system." - :type '(choice (const :tag "No passwd file" nil) file) - :group 'eshell-util) + :type '(choice (const :tag "No passwd file" nil) file)) (defcustom eshell-hosts-file "/etc/hosts" "The name of the /etc/hosts file. Use `pcomplete-hosts-file' instead; this variable is obsolete and has no effect." - :type '(choice (const :tag "No hosts file" nil) file) - :group 'eshell-util) + :type '(choice (const :tag "No hosts file" nil) file)) ;; Don't make it into an alias, because it doesn't really work with ;; custom and risks creating duplicate entries. Just point users to ;; the other variable, which is less frustrating. @@ -64,25 +61,21 @@ has no effect." (defcustom eshell-handle-errors t "If non-nil, Eshell will handle errors itself. Setting this to nil is offered as an aid to debugging only." - :type 'boolean - :group 'eshell-util) + :type 'boolean) (defcustom eshell-private-file-modes 384 ; umask 177 "The file-modes value to use for creating \"private\" files." - :type 'integer - :group 'eshell-util) + :type 'integer) (defcustom eshell-private-directory-modes 448 ; umask 077 "The file-modes value to use for creating \"private\" directories." - :type 'integer - :group 'eshell-util) + :type 'integer) (defcustom eshell-tar-regexp "\\.t\\(ar\\(\\.\\(gz\\|bz2\\|xz\\|Z\\)\\)?\\|gz\\|a[zZ]\\|z2\\)\\'" "Regular expression used to match tar file names." :version "24.1" ; added xz - :type 'regexp - :group 'eshell-util) + :type 'regexp) (defcustom eshell-convert-numeric-arguments t "If non-nil, converting arguments of numeric form to Lisp numbers. @@ -99,16 +92,14 @@ following in your init file: Any function with the property `eshell-no-numeric-conversions' set to a non-nil value, will be passed strings, not numbers, even when an argument matches `eshell-number-regexp'." - :type 'boolean - :group 'eshell-util) + :type 'boolean) (defcustom eshell-number-regexp "-?\\([0-9]*\\.\\)?[0-9]+\\(e[-0-9.]+\\)?" "Regular expression used to match numeric arguments. If `eshell-convert-numeric-arguments' is non-nil, and an argument matches this regexp, it will be converted to a Lisp number, using the function `string-to-number'." - :type 'regexp - :group 'eshell-util) + :type 'regexp) (defcustom eshell-ange-ls-uids nil "List of user/host/id strings, used to determine remote ownership." @@ -116,8 +107,7 @@ function `string-to-number'." (string :tag "Hostname") (repeat (cons :tag "User/UID List" (string :tag "Username") - (repeat :tag "UIDs" string))))) - :group 'eshell-util) + (repeat :tag "UIDs" string)))))) ;;; Internal Variables: @@ -308,11 +298,11 @@ Prepend remote identification of `default-directory', if any." (defsubst eshell-stringify-list (args) "Convert each element of ARGS into a string value." - (mapcar 'eshell-stringify args)) + (mapcar #'eshell-stringify args)) (defsubst eshell-flatten-and-stringify (&rest args) "Flatten and stringify all of the ARGS into a single string." - (mapconcat 'eshell-stringify (flatten-tree args) " ")) + (mapconcat #'eshell-stringify (flatten-tree args) " ")) (defsubst eshell-directory-files (regexp &optional directory) "Return a list of files in the given DIRECTORY matching REGEXP." @@ -471,7 +461,7 @@ list." (defsubst eshell-copy-environment () "Return an unrelated copy of `process-environment'." - (mapcar 'concat process-environment)) + (mapcar #'concat process-environment)) (defun eshell-subgroups (groupsym) "Return all of the subgroups of GROUPSYM." @@ -619,70 +609,68 @@ gid format. Valid values are `string' and `integer', defaulting to "If the `processp' function does not exist, PROC is not a process." (and (fboundp 'processp) (processp proc))) -; (defun eshell-copy-file -; (file newname &optional ok-if-already-exists keep-date) -; "Copy FILE to NEWNAME. See docs for `copy-file'." -; (let (copied) -; (if (string-match "\\`\\([^:]+\\):\\(.*\\)" file) -; (let ((front (match-string 1 file)) -; (back (match-string 2 file)) -; buffer) -; (if (and front (string-match eshell-tar-regexp front) -; (setq buffer (find-file-noselect front))) -; (with-current-buffer buffer -; (goto-char (point-min)) -; (if (re-search-forward (concat " " (regexp-quote back) -; "$") nil t) -; (progn -; (tar-copy (if (file-directory-p newname) -; (expand-file-name -; (file-name-nondirectory back) newname) -; newname)) -; (setq copied t)) -; (error "%s not found in tar file %s" back front)))))) -; (unless copied -; (copy-file file newname ok-if-already-exists keep-date)))) - -; (defun eshell-file-attributes (filename) -; "Return a list of attributes of file FILENAME. -; See the documentation for `file-attributes'." -; (let (result) -; (when (string-match "\\`\\([^:]+\\):\\(.*\\)\\'" filename) -; (let ((front (match-string 1 filename)) -; (back (match-string 2 filename)) -; buffer) -; (when (and front (string-match eshell-tar-regexp front) -; (setq buffer (find-file-noselect front))) -; (with-current-buffer buffer -; (goto-char (point-min)) -; (when (re-search-forward (concat " " (regexp-quote back) -; "\\s-*$") nil t) -; (let* ((descrip (tar-current-descriptor)) -; (tokens (tar-desc-tokens descrip))) -; (setq result -; (list -; (cond -; ((eq (tar-header-link-type tokens) 5) -; t) -; ((eq (tar-header-link-type tokens) t) -; (tar-header-link-name tokens))) -; 1 -; (tar-header-uid tokens) -; (tar-header-gid tokens) -; (tar-header-date tokens) -; (tar-header-date tokens) -; (tar-header-date tokens) -; (tar-header-size tokens) -; (concat -; (cond -; ((eq (tar-header-link-type tokens) 5) "d") -; ((eq (tar-header-link-type tokens) t) "l") -; (t "-")) -; (tar-grind-file-mode (tar-header-mode tokens) -; (make-string 9 ? ) 0)) -; nil nil nil)))))))) -; (or result -; (file-attributes filename)))) +;; (defun eshell-copy-file +;; (file newname &optional ok-if-already-exists keep-date) +;; "Copy FILE to NEWNAME. See docs for `copy-file'." +;; (let (copied) +;; (if (string-match "\\`\\([^:]+\\):\\(.*\\)" file) +;; (let ((front (match-string 1 file)) +;; (back (match-string 2 file)) +;; buffer) +;; (if (and front (string-match eshell-tar-regexp front) +;; (setq buffer (find-file-noselect front))) +;; (with-current-buffer buffer +;; (goto-char (point-min)) +;; (if (re-search-forward (concat " " (regexp-quote back) +;; "$") nil t) +;; (progn +;; (tar-copy (if (file-directory-p newname) +;; (expand-file-name +;; (file-name-nondirectory back) newname) +;; newname)) +;; (setq copied t)) +;; (error "%s not found in tar file %s" back front)))))) +;; (unless copied +;; (copy-file file newname ok-if-already-exists keep-date)))) + +;; (defun eshell-file-attributes (filename) +;; "Return a list of attributes of file FILENAME. +;; See the documentation for `file-attributes'." +;; (let (result) +;; (when (string-match "\\`\\([^:]+\\):\\(.*\\)\\'" filename) +;; (let ((front (match-string 1 filename)) +;; (back (match-string 2 filename)) +;; buffer) +;; (when (and front (string-match eshell-tar-regexp front) +;; (setq buffer (find-file-noselect front))) +;; (with-current-buffer buffer +;; (goto-char (point-min)) +;; (when (re-search-forward (concat " " (regexp-quote back) +;; "\\s-*$") nil t) +;; (let* ((descrip (tar-current-descriptor)) +;; (tokens (tar-desc-tokens descrip))) +;; (setq result +;; (list +;; (cond +;; ((eq (tar-header-link-type tokens) 5) +;; t) +;; ((eq (tar-header-link-type tokens) t) +;; (tar-header-link-name tokens))) +;; 1 +;; (tar-header-uid tokens) +;; (tar-header-gid tokens) +;; (tar-header-date tokens) +;; (tar-header-date tokens) +;; (tar-header-date tokens) +;; (tar-header-size tokens) +;; (file-modes-number-to-symbolic +;; (logior (tar-header-mode tokens) +;; (cond +;; ((eq (tar-header-link-type tokens) 5) 16384) +;; ((eq (tar-header-link-type tokens) t) 32768)))) +;; nil nil nil)))))))) +;; (or result +;; (file-attributes filename)))) ;; Obsolete. commit 24073c6479b2aefa13f7f9c87697ad38e0144203 Author: Stefan Monnier Date: Sun Apr 11 22:42:36 2021 -0400 * lisp/eshell/esh-proc.el (eshell-kill-process-function): Use `remove-hook` Also remove redundant `:group` args diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index 369382906c..96c9a60dea 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -37,23 +37,19 @@ finish." (defcustom eshell-proc-load-hook nil "A hook that gets run when `eshell-proc' is loaded." :version "24.1" ; removed eshell-proc-initialize - :type 'hook - :group 'eshell-proc) + :type 'hook) (defcustom eshell-process-wait-seconds 0 "The number of seconds to delay waiting for a synchronous process." - :type 'integer - :group 'eshell-proc) + :type 'integer) (defcustom eshell-process-wait-milliseconds 50 "The number of milliseconds to delay waiting for a synchronous process." - :type 'integer - :group 'eshell-proc) + :type 'integer) (defcustom eshell-done-messages-in-minibuffer t "If non-nil, subjob \"Done\" messages will display in minibuffer." - :type 'boolean - :group 'eshell-proc) + :type 'boolean) (defcustom eshell-delete-exited-processes t "If nil, process entries will stick around until `jobs' is run. @@ -72,14 +68,12 @@ subjob is done is that it will no longer appear in the Note that Eshell will have to be restarted for a change in this variable's value to take effect." - :type 'boolean - :group 'eshell-proc) + :type 'boolean) (defcustom eshell-reset-signals "^\\(interrupt\\|killed\\|quit\\|stopped\\)" "If a termination signal matches this regexp, the terminal will be reset." - :type 'regexp - :group 'eshell-proc) + :type 'regexp) (defcustom eshell-exec-hook nil "Called each time a process is exec'd by `eshell-gather-process-output'. @@ -88,8 +82,7 @@ It is useful for things that must be done each time a process is executed in an eshell mode buffer (e.g., `set-process-query-on-exit-flag'). In contrast, `eshell-mode-hook' is only executed once, when the buffer is created." - :type 'hook - :group 'eshell-proc) + :type 'hook) (defcustom eshell-kill-hook nil "Called when a process run by `eshell-gather-process-output' has ended. @@ -99,8 +92,7 @@ nil, in which case the user attempted to send a signal, but there was no relevant process. This can be used for displaying help information, for example." :version "24.1" ; removed eshell-reset-after-proc - :type 'hook - :group 'eshell-proc) + :type 'hook) ;;; Internal Variables: @@ -126,8 +118,7 @@ information, for example." Runs `eshell-reset-after-proc' and `eshell-kill-hook', passing arguments PROC and STATUS to functions on the latter." ;; Was there till 24.1, but it is not optional. - (if (memq #'eshell-reset-after-proc eshell-kill-hook) - (setq eshell-kill-hook (delq #'eshell-reset-after-proc eshell-kill-hook))) + (remove-hook 'eshell-kill-hook #'eshell-reset-after-proc) (eshell-reset-after-proc status) (run-hook-with-args 'eshell-kill-hook proc status)) @@ -165,7 +156,7 @@ The signals which will cause this to happen are matched by eshell-process-wait-milliseconds)))) (setq procs (cdr procs)))) -(defalias 'eshell/wait 'eshell-wait-for-process) +(defalias 'eshell/wait #'eshell-wait-for-process) (defun eshell/jobs (&rest _args) "List processes, if there are any." @@ -457,8 +448,7 @@ If QUERY is non-nil, query the user with QUERY before calling FUNC." (defcustom eshell-kill-process-wait-time 5 "Seconds to wait between sending termination signals to a subprocess." - :type 'integer - :group 'eshell-proc) + :type 'integer) (defcustom eshell-kill-process-signals '(SIGINT SIGQUIT SIGKILL) "Signals used to kill processes when an Eshell buffer exits. @@ -466,8 +456,7 @@ Eshell calls each of these signals in order when an Eshell buffer is killed; if the process is still alive afterwards, Eshell waits a number of seconds defined by `eshell-kill-process-wait-time', and tries the next signal in the list." - :type '(repeat symbol) - :group 'eshell-proc) + :type '(repeat symbol)) (defcustom eshell-kill-processes-on-exit nil "If non-nil, kill active processes when exiting an Eshell buffer. @@ -489,8 +478,7 @@ long to delay between signals." :type '(choice (const :tag "Kill all, don't ask" t) (const :tag "Ask before killing" ask) (const :tag "Ask for each process" every) - (const :tag "Don't kill subprocesses" nil)) - :group 'eshell-proc) + (const :tag "Don't kill subprocesses" nil))) (defun eshell-round-robin-kill (&optional query) "Kill current process by trying various signals in sequence. commit 954ce51d7a30e7d20bebbb3205c69e9b80181c34 Author: Stefan Monnier Date: Sun Apr 11 22:38:34 2021 -0400 * lisp/mail/rmailmm.el (rmail-mime): Simplify interactive spec diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el index cdb994a5c8..e08500a189 100644 --- a/lisp/mail/rmailmm.el +++ b/lisp/mail/rmailmm.el @@ -1402,7 +1402,7 @@ are handled according to `rmail-mime-media-type-handlers-alist'. By default, this displays text and multipart messages, and offers to download attachments as specified by `rmail-mime-attachment-dirs-alist'. The arguments ARG and STATE have no effect in this case." - (interactive (list current-prefix-arg nil)) + (interactive) (if rmail-enable-mime (with-current-buffer rmail-buffer (if (or (rmail-mime-message-p) commit 828e688bef468fb80b291739529e3d4e2d79eddd Author: Stefan Monnier Date: Sun Apr 11 22:34:58 2021 -0400 * lisp/progmodes/sql.el (sql-mode-ansi-font-lock-keywords): Fix declaration diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 6224b3b5f3..6e53a04f72 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -1545,9 +1545,7 @@ statement. The format of variable should be a valid ;; `sql-font-lock-keywords-builder' function and follow the ;; implementation pattern used for the other products in this file. -(eval-when-compile - (defvar sql-mode-ansi-font-lock-keywords) - (setq sql-mode-ansi-font-lock-keywords nil)) +(defvar sql-mode-ansi-font-lock-keywords) (eval-and-compile (defun sql-font-lock-keywords-builder (face boundaries &rest keywords) commit 28a5932e745faee66ce7b23f4c102d29083519e7 Author: Stefan Monnier Date: Sun Apr 11 22:27:25 2021 -0400 * lisp/vc/log-edit.el (log-edit-diff-function): Give non-nil default (log-edit-show-diff): Simplify accordingly. diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el index 56b3166221..eabbaba32c 100644 --- a/lisp/vc/log-edit.el +++ b/lisp/vc/log-edit.el @@ -191,7 +191,8 @@ when this variable is set to nil.") (defconst log-edit-files-buf "*log-edit-files*") (defvar log-edit-initial-files nil) (defvar log-edit-callback nil) -(defvar log-edit-diff-function nil) +(defvar log-edit-diff-function + (lambda () (error "Diff functionality has not been setup"))) (defvar log-edit-listfun nil) (defvar log-edit-parent-buffer nil) @@ -659,9 +660,7 @@ Also saves its contents in the comment history and hides (defun log-edit-show-diff () "Show the diff for the files to be committed." (interactive) - (if (functionp log-edit-diff-function) - (funcall log-edit-diff-function) - (error "Diff functionality has not been setup"))) + (funcall log-edit-diff-function)) (defun log-edit-show-files () "Show the list of files to be committed." commit 4315a0bb267e8fca16552001e3ab897f69ef8d70 Author: Stefan Monnier Date: Sun Apr 11 18:02:34 2021 -0400 * lisp/progmodes/bug-reference.el: Avoid old-style `define-minor-mode` (bug-reference-mode, bug-reference-prog-mode): Remove redundant args. diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index 4d4becf780..e467d98303 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -440,9 +440,6 @@ and set it if applicable." ;;;###autoload (define-minor-mode bug-reference-mode "Toggle hyperlinking bug references in the buffer (Bug Reference mode)." - nil - "" - nil :after-hook (bug-reference--run-auto-setup) (if bug-reference-mode (jit-lock-register #'bug-reference-fontify) @@ -454,9 +451,6 @@ and set it if applicable." ;;;###autoload (define-minor-mode bug-reference-prog-mode "Like `bug-reference-mode', but only buttonize in comments and strings." - nil - "" - nil :after-hook (bug-reference--run-auto-setup) (if bug-reference-prog-mode (jit-lock-register #'bug-reference-fontify) commit d37f0f3ac34f09830a881280131980f875d075d3 Author: Philipp Stephani Date: Mon Dec 14 21:25:11 2020 +0100 * src/emacs.c (load_seccomp): Consistently check for nonzero result diff --git a/src/emacs.c b/src/emacs.c index 694d975ec3..362e4a2cc5 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1079,7 +1079,7 @@ load_seccomp (const char *file) file); goto out; } - if (emacs_close (fd) < 0) + if (emacs_close (fd) != 0) emacs_perror ("close"); /* not a fatal error */ fd = -1; program.len = count; commit c8d542fd593f06b85d4b7b712378a4f84ec4d2b3 Author: Philipp Stephani Date: Sun Apr 11 19:47:36 2021 +0200 Add a variant of the Seccomp filter file that allows 'execve'. This is useful when starting Emacs with a Seccomp filter enabled, e.g. using 'bwrap'. * lib-src/seccomp-filter.c (main): Generate new Seccomp files. * lib-src/Makefile.in (all) (seccomp-filter.bpf seccomp-filter.pfc seccomp-filter-exec.bpf seccomp-filter-exec.pfc): Generate new Seccomp files. * .gitignore: Ignore new Seccomp files. * test/src/emacs-tests.el (emacs-tests/bwrap/allows-stdout): New unit test. diff --git a/.gitignore b/.gitignore index ecf768dc4d..a1e3cb92f8 100644 --- a/.gitignore +++ b/.gitignore @@ -306,3 +306,5 @@ src/gdb.ini # Seccomp filter files. lib-src/seccomp-filter.bpf lib-src/seccomp-filter.pfc +lib-src/seccomp-filter-exec.bpf +lib-src/seccomp-filter-exec.pfc diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 35cfa56d8b..091f4fb019 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -240,7 +240,7 @@ config_h = ../src/config.h $(srcdir)/../src/conf_post.h all: ${EXE_FILES} ${SCRIPTS} ifeq ($(SECCOMP_FILTER),1) -all: seccomp-filter.bpf +all: seccomp-filter.bpf seccomp-filter-exec.bpf endif .PHONY: all need-blessmail maybe-blessmail @@ -430,9 +430,10 @@ seccomp-filter$(EXEEXT): $(srcdir)/seccomp-filter.c $(config_h) $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $(LIBSECCOMP_CFLAGS) $< \ $(LIBSECCOMP_LIBS) -o $@ -seccomp-filter.bpf seccomp-filter.pfc: seccomp-filter$(EXEEXT) +seccomp-filter.bpf seccomp-filter.pfc seccomp-filter-exec.bpf seccomp-filter-exec.pfc: seccomp-filter$(EXEEXT) $(AM_V_GEN)./seccomp-filter$(EXEEXT) \ - seccomp-filter.bpf seccomp-filter.pfc + seccomp-filter.bpf seccomp-filter.pfc \ + seccomp-filter-exec.bpf seccomp-filter-exec.pfc endif ## Makefile ends here. diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c index a5f2e0adbc..ed362bc18d 100644 --- a/lib-src/seccomp-filter.c +++ b/lib-src/seccomp-filter.c @@ -26,10 +26,12 @@ only a Linux kernel supporting the Secure Computing extension. Usage: - seccomp-filter out.bpf out.pfc + seccomp-filter out.bpf out.pfc out-exec.bpf out-exec.pfc This writes the raw `struct sock_filter' array to out.bpf and a -human-readable representation to out.pfc. */ +human-readable representation to out.pfc. Additionally, it writes +variants of those files that can be used to sandbox Emacs before +'execve' to out-exec.bpf and out-exec.pfc. */ #include "config.h" @@ -42,6 +44,7 @@ human-readable representation to out.pfc. */ #include #include +#include #include #include #include @@ -139,8 +142,9 @@ export_filter (const char *file, int main (int argc, char **argv) { - if (argc != 3) - fail (0, "usage: %s out.bpf out.pfc", argv[0]); + if (argc != 5) + fail (0, "usage: %s out.bpf out.pfc out-exec.bpf out-exec.pfc", + argv[0]); /* Any unhandled syscall should abort the Emacs process. */ ctx = seccomp_init (SCMP_ACT_KILL_PROCESS); @@ -156,6 +160,8 @@ main (int argc, char **argv) verify (CHAR_BIT == 8); verify (sizeof (int) == 4 && INT_MIN == INT32_MIN && INT_MAX == INT32_MAX); + verify (sizeof (long) == 8 && LONG_MIN == INT64_MIN + && LONG_MAX == INT64_MAX); verify (sizeof (void *) == 8); verify ((uintptr_t) NULL == 0); @@ -327,4 +333,29 @@ main (int argc, char **argv) EXPORT_FILTER (argv[1], seccomp_export_bpf); EXPORT_FILTER (argv[2], seccomp_export_pfc); + + /* When applying a Seccomp filter before executing the Emacs binary + (e.g. using the `bwrap' program), we need to allow further system + calls. Firstly, the wrapper binary will need to `execve' the + Emacs binary. Furthermore, the C library requires some system + calls at startup time to set up thread-local storage. */ + RULE (SCMP_ACT_ALLOW, SCMP_SYS (execve)); + RULE (SCMP_ACT_ALLOW, SCMP_SYS (set_tid_address)); + RULE (SCMP_ACT_ALLOW, SCMP_SYS (arch_prctl), + SCMP_A0_32 (SCMP_CMP_EQ, ARCH_SET_FS)); + RULE (SCMP_ACT_ALLOW, SCMP_SYS (statfs)); + + /* We want to allow starting the Emacs binary itself with the + --seccomp flag, so we need to allow the `prctl' and `seccomp' + system calls. */ + RULE (SCMP_ACT_ALLOW, SCMP_SYS (prctl), + SCMP_A0_32 (SCMP_CMP_EQ, PR_SET_NO_NEW_PRIVS), + SCMP_A1_64 (SCMP_CMP_EQ, 1), SCMP_A2_64 (SCMP_CMP_EQ, 0), + SCMP_A3_64 (SCMP_CMP_EQ, 0), SCMP_A4_64 (SCMP_CMP_EQ, 0)); + RULE (SCMP_ACT_ALLOW, SCMP_SYS (seccomp), + SCMP_A0_32 (SCMP_CMP_EQ, SECCOMP_SET_MODE_FILTER), + SCMP_A1_32 (SCMP_CMP_EQ, SECCOMP_FILTER_FLAG_TSYNC)); + + EXPORT_FILTER (argv[3], seccomp_export_bpf); + EXPORT_FILTER (argv[4], seccomp_export_pfc); } diff --git a/test/src/emacs-resources/seccomp-filter-exec.bpf b/test/src/emacs-resources/seccomp-filter-exec.bpf new file mode 120000 index 0000000000..5b0e997822 --- /dev/null +++ b/test/src/emacs-resources/seccomp-filter-exec.bpf @@ -0,0 +1 @@ +../../../lib-src/seccomp-filter-exec.bpf \ No newline at end of file diff --git a/test/src/emacs-tests.el b/test/src/emacs-tests.el index 89d811f8b4..09f9a248ef 100644 --- a/test/src/emacs-tests.el +++ b/test/src/emacs-tests.el @@ -177,4 +177,37 @@ to `make-temp-file', which see." (ert-info ((format "Process output: %s" (buffer-string))) (should-not (eql status 0))))))) +(ert-deftest emacs-tests/bwrap/allows-stdout () + (let ((bash (executable-find "bash")) + (bwrap (executable-find "bwrap")) + (emacs + (expand-file-name invocation-name invocation-directory)) + (filter (ert-resource-file "seccomp-filter-exec.bpf")) + (process-environment nil)) + (skip-unless bash) + (skip-unless bwrap) + (skip-unless (file-executable-p emacs)) + (skip-unless (file-readable-p filter)) + (should-not (file-remote-p bwrap)) + (should-not (file-remote-p emacs)) + (should-not (file-remote-p filter)) + (with-temp-buffer + (let* ((command + (concat + (mapconcat #'shell-quote-argument + `(,(file-name-unquote bwrap) + "--ro-bind" "/" "/" + "--seccomp" "20" + "--" + ,(file-name-unquote emacs) + "--quick" "--batch" + ,(format "--eval=%S" '(message "Hi"))) + " ") + " 20< " + (shell-quote-argument (file-name-unquote filter)))) + (status (call-process bash nil t nil "-c" command))) + (ert-info ((format "Process output: %s" (buffer-string))) + (should (eql status 0))) + (should (equal (string-trim (buffer-string)) "Hi")))))) + ;;; emacs-tests.el ends here commit cf0701eff0f3b06e0324be07f7810cbaf261f7f3 Author: Philipp Stephani Date: Sun Apr 11 21:14:09 2021 +0200 * lib-src/seccomp-filter.c (main): Also allow O_NOFOLLOW. diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c index 9d25a5fe14..a5f2e0adbc 100644 --- a/lib-src/seccomp-filter.c +++ b/lib-src/seccomp-filter.c @@ -241,12 +241,12 @@ main (int argc, char **argv) RULE (SCMP_ACT_ALLOW, SCMP_SYS (open), SCMP_A1_32 (SCMP_CMP_MASKED_EQ, ~(O_RDONLY | O_BINARY | O_CLOEXEC | O_PATH - | O_DIRECTORY), + | O_DIRECTORY | O_NOFOLLOW), 0)); RULE (SCMP_ACT_ALLOW, SCMP_SYS (openat), SCMP_A2_32 (SCMP_CMP_MASKED_EQ, ~(O_RDONLY | O_BINARY | O_CLOEXEC | O_PATH - | O_DIRECTORY), + | O_DIRECTORY | O_NOFOLLOW), 0)); /* Allow `tcgetpgrp'. */ commit 9a57897ea1a125782ff332814d3f978c38162cf8 Author: Philipp Stephani Date: Sun Apr 11 19:35:39 2021 +0200 Don't attempt to generate Seccomp filter file in Linux < 4.14. Only Linux 4.14 and later contain the required support for SECCOMP_RET_KILL_PROCESS. * lib-src/Makefile.in (SECCOMP_FILTER): Define only if we run at least Linux 4.14. diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index b4143b3355..35cfa56d8b 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -196,9 +196,15 @@ LIBSECCOMP_CFLAGS=@LIBSECCOMP_CFLAGS@ # Currently, we can only generate seccomp filter files for x86-64. ifeq ($(HAVE_LIBSECCOMP),yes) ifeq ($(shell uname -m),x86_64) +# We require SECCOMP_RET_KILL_PROCESS, which is only available in +# Linux 4.14 and later. +ifeq ($(shell { echo 4.14; uname -r | cut -d . -f 1-2; } | \ + sort -C -t . -n -k 1,1 -k 2,2 && \ + echo 1),1) SECCOMP_FILTER=1 endif endif +endif ifeq ($(SECCOMP_FILTER),1) DONT_INSTALL += seccomp-filter$(EXEEXT) commit ea5ea09244b762008bba509d8c58bad5835fb949 Author: Philipp Stephani Date: Sun Apr 11 19:42:44 2021 +0200 Seccomp filter: allow reading the current time (Bug#47708). * lib-src/seccomp-filter.c (main): Allow reading the current time. diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c index e4d56e01b4..9d25a5fe14 100644 --- a/lib-src/seccomp-filter.c +++ b/lib-src/seccomp-filter.c @@ -40,6 +40,7 @@ human-readable representation to out.pfc. */ #include #include #include +#include #include #include @@ -286,6 +287,12 @@ main (int argc, char **argv) RULE (SCMP_ACT_ALLOW, SCMP_SYS (sigprocmask)); RULE (SCMP_ACT_ALLOW, SCMP_SYS (rt_sigprocmask)); + /* Allow reading the current time. */ + RULE (SCMP_ACT_ALLOW, SCMP_SYS (clock_gettime), + SCMP_A0_32 (SCMP_CMP_EQ, CLOCK_REALTIME)); + RULE (SCMP_ACT_ALLOW, SCMP_SYS (time)); + RULE (SCMP_ACT_ALLOW, SCMP_SYS (gettimeofday)); + /* Allow timer support. */ RULE (SCMP_ACT_ALLOW, SCMP_SYS (timer_create)); RULE (SCMP_ACT_ALLOW, SCMP_SYS (timerfd_create)); commit 751e801f90339480ea43fc2237fc45c8eb39bd6f Author: Andreas Schwab Date: Sun Apr 11 17:23:22 2021 +0200 Fix check for timer_getoverrun * configure.ac (timer_getoverrun): Move check after gnulib checks and use $LIB_TIMER_TIME during check. diff --git a/configure.ac b/configure.ac index 681c25b052..169ffc5534 100644 --- a/configure.ac +++ b/configure.ac @@ -4201,7 +4201,7 @@ getrusage get_current_dir_name \ lrand48 random rint trunc \ select getpagesize setlocale newlocale \ getrlimit setrlimit shutdown \ -pthread_sigmask strsignal setitimer timer_getoverrun \ +pthread_sigmask strsignal setitimer \ sendto recvfrom getsockname getifaddrs freeifaddrs \ gai_strerror sync \ getpwent endpwent getgrent endgrent \ @@ -5498,6 +5498,12 @@ gl_INIT CFLAGS=$SAVE_CFLAGS LIBS=$SAVE_LIBS +# timer_getoverrun needs the same libarary as timer_settime +OLD_LIBS=$LIBS +LIBS="$LIB_TIMER_TIME $LIBS" +AC_CHECK_FUNCS(timer_getoverrun) +LIBS=$OLD_LIBS + if test "${opsys}" = "mingw32"; then CPPFLAGS="$CPPFLAGS -DUSE_CRT_DLL=1 -I \${abs_top_srcdir}/nt/inc" # Remove unneeded switches from the value of CC that goes to Makefiles commit 725fc96b706c57ef8ceca5e7d82b175d9a72e845 Author: Philipp Stephani Date: Sun Apr 11 16:50:29 2021 +0200 Use pkg-config to check for libseccomp. We need at list version 2.4.0 of libseccomp for seccomp-filter.c to build cleanly. * configure.ac: Use pkg-config to check for libseccomp. * lib-src/Makefile.in (HAVE_LIBSECCOMP, LIBSECCOMP_LIBS) (LIBSECCOMP_CFLAGS): New variables. (SECCOMP_FILTER, seccomp-filter$(EXEEXT)): Use them. diff --git a/configure.ac b/configure.ac index cb4a9ab287..681c25b052 100644 --- a/configure.ac +++ b/configure.ac @@ -4189,10 +4189,10 @@ AC_CHECK_HEADERS( #include ]])]) -LIBSECCOMP= -AC_CHECK_HEADER([seccomp.h], - [AC_CHECK_LIB([seccomp], [seccomp_init], [LIBSECCOMP=-lseccomp])]) -AC_SUBST([LIBSECCOMP]) +EMACS_CHECK_MODULES([LIBSECCOMP], [libseccomp >= 2.4.0]) +AC_SUBST([HAVE_LIBSECCOMP]) +AC_SUBST([LIBSECCOMP_LIBS]) +AC_SUBST([LIBSECCOMP_CFLAGS]) OLD_LIBS=$LIBS LIBS="$LIB_PTHREAD $LIB_MATH $LIBS" diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 5870286cd5..b4143b3355 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -189,10 +189,12 @@ LIB_WSOCK32=@LIB_WSOCK32@ ## Extra libraries for etags LIBS_ETAGS = $(LIB_CLOCK_GETTIME) $(LIB_GETRANDOM) -LIBSECCOMP=@LIBSECCOMP@ +HAVE_LIBSECCOMP=@HAVE_LIBSECCOMP@ +LIBSECCOMP_LIBS=@LIBSECCOMP_LIBS@ +LIBSECCOMP_CFLAGS=@LIBSECCOMP_CFLAGS@ # Currently, we can only generate seccomp filter files for x86-64. -ifneq ($(LIBSECCOMP),) +ifeq ($(HAVE_LIBSECCOMP),yes) ifeq ($(shell uname -m),x86_64) SECCOMP_FILTER=1 endif @@ -419,7 +421,8 @@ emacsclient.res: ../nt/emacsclient.rc $(NTINC)/../icons/emacs.ico ifeq ($(SECCOMP_FILTER),1) seccomp-filter$(EXEEXT): $(srcdir)/seccomp-filter.c $(config_h) - $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $< $(LIBSECCOMP) -o $@ + $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $(LIBSECCOMP_CFLAGS) $< \ + $(LIBSECCOMP_LIBS) -o $@ seccomp-filter.bpf seccomp-filter.pfc: seccomp-filter$(EXEEXT) $(AM_V_GEN)./seccomp-filter$(EXEEXT) \ commit d06c54db1b3504caed8673216a72b117d0692351 Author: Philipp Stephani Date: Sun Apr 11 16:41:44 2021 +0200 Remove SCMP_FLTATR_CTL_LOG attribute from Seccomp filter. Whether or not we log failing syscalls isn't security-critical, and we shouldn't care. * lib-src/seccomp-filter.c (main): Remove log attribute. diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c index 77e4413d3d..e4d56e01b4 100644 --- a/lib-src/seccomp-filter.c +++ b/lib-src/seccomp-filter.c @@ -151,7 +151,6 @@ main (int argc, char **argv) set_attribute (SCMP_FLTATR_ACT_BADARCH, SCMP_ACT_KILL_PROCESS); set_attribute (SCMP_FLTATR_CTL_NNP, 1); set_attribute (SCMP_FLTATR_CTL_TSYNC, 1); - set_attribute (SCMP_FLTATR_CTL_LOG, 0); verify (CHAR_BIT == 8); verify (sizeof (int) == 4 && INT_MIN == INT32_MIN commit 9dc26d4a8add5b3f2a5fce7907af4f9673ae82c0 Author: Philipp Stephani Date: Sun Apr 11 16:22:54 2021 +0200 Only attempt to generate seccomp filter files on x86-64 systems. The seccomp filters are always architecture-specific, and seccomp-filter.c right now only supports x86-64. * lib-src/Makefile.in (SECCOMP_FILTER): New variable. (DONT_INSTALL, all, seccomp-filter$(EXEEXT)): Use it. diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index 1942882004..5870286cd5 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -191,7 +191,14 @@ LIBS_ETAGS = $(LIB_CLOCK_GETTIME) $(LIB_GETRANDOM) LIBSECCOMP=@LIBSECCOMP@ +# Currently, we can only generate seccomp filter files for x86-64. ifneq ($(LIBSECCOMP),) +ifeq ($(shell uname -m),x86_64) +SECCOMP_FILTER=1 +endif +endif + +ifeq ($(SECCOMP_FILTER),1) DONT_INSTALL += seccomp-filter$(EXEEXT) endif @@ -224,7 +231,7 @@ config_h = ../src/config.h $(srcdir)/../src/conf_post.h all: ${EXE_FILES} ${SCRIPTS} -ifneq ($(LIBSECCOMP),) +ifeq ($(SECCOMP_FILTER),1) all: seccomp-filter.bpf endif @@ -410,7 +417,7 @@ update-game-score${EXEEXT}: ${srcdir}/update-game-score.c $(NTLIB) $(config_h) emacsclient.res: ../nt/emacsclient.rc $(NTINC)/../icons/emacs.ico $(AM_V_RC)$(WINDRES) -O coff --include-dir=$(NTINC)/.. -o $@ $< -ifneq ($(LIBSECCOMP),) +ifeq ($(SECCOMP_FILTER),1) seccomp-filter$(EXEEXT): $(srcdir)/seccomp-filter.c $(config_h) $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $< $(LIBSECCOMP) -o $@ commit 6b3ca89cac15f56c1d7980727bce8e24834d4949 Author: Eli Zaretskii Date: Sun Apr 11 17:04:07 2021 +0300 ; * etc/NEWS: Minor copyedits. diff --git a/etc/NEWS b/etc/NEWS index aaf38022c5..7483a6e5b7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -91,9 +91,9 @@ true color by setting 'COLORTERM=truecolor' in the environment. This is useful on systems such as FreeBSD which ships only with "etc/termcap". ** Emacs now supports loading a Secure Computing filter. -This is supported only on capable GNU/Linux systems. To use this, -use the '--seccomp=FILE' command-line option when starting Emacs. -FILE must name a binary file containing an array of 'struct sock_filter' +This is supported only on capable GNU/Linux systems. To activate, +invoke Emacs with the '--seccomp=FILE' command-line option. FILE must +name a binary file containing an array of 'struct sock_filter' structures. Emacs will then install that list of Secure Computing filters into its own process early during the startup process. You can use this functionality to put an Emacs process in a sandbox to commit 553783628892a5363aacf58ce238969cb60a1c3a Author: Philipp Stephani Date: Sun Apr 11 16:02:05 2021 +0200 * lib-src/seccomp-filter.c: Print trailing newline. diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c index eeca75fddf..77e4413d3d 100644 --- a/lib-src/seccomp-filter.c +++ b/lib-src/seccomp-filter.c @@ -60,7 +60,10 @@ fail (int error, const char *format, ...) va_list ap; va_start (ap, format); if (error == 0) - vfprintf (stderr, format, ap); + { + vfprintf (stderr, format, ap); + fputc ('\n', stderr); + } else { char buffer[1000]; commit dac5af2ba15ee8006ba0c223b11e1dfb237e2255 Author: Stefan Kangas Date: Sun Apr 11 14:14:42 2021 +0200 * doc/lispref/elisp.texi (Top): Add missing entry. diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index dade855518..be0c835b03 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi @@ -531,6 +531,7 @@ Scoping Rules for Variable Bindings * Dynamic Binding Tips:: Avoiding problems with dynamic binding. * Lexical Binding:: A different type of local variable binding. * Using Lexical Binding:: How to enable lexical binding. +* Converting to Lexical Binding:: Convert existing code to lexical binding. Buffer-Local Variables commit 686c366f8a63c448d06e5f08d604374fb316bc57 Author: Eli Barzilay Date: Sat Apr 10 15:10:35 2021 -0400 Fix calculator-string-to-number yet again (bug#47694) * lisp/calculator.el (calculator-string-to-number): The last bugfix changed the code to just blindly replace ".e". This has some minor problems like making "-." parse as 0.0 instead of -0.0, and ".1.e1" is parsed as 1 instead of 0.1. Instead, replace the first "." that is followed by a non-digit with ".0". Since this has had several problems over the years, add some tests too. (Also, restore the original if-indentation style.) diff --git a/lisp/calculator.el b/lisp/calculator.el index 6dd8d9a7ec..99c9b6290c 100644 --- a/lisp/calculator.el +++ b/lisp/calculator.el @@ -836,10 +836,11 @@ The result should not exceed the screen width." "Convert the given STR to a number, according to the value of `calculator-input-radix'." (if calculator-input-radix - (string-to-number str (cadr (assq calculator-input-radix - '((bin 2) (oct 8) (hex 16))))) - ;; Allow entry of "1.e3". - (let ((str (replace-regexp-in-string (rx "." (any "eE")) "e" str))) + (string-to-number str (cadr (assq calculator-input-radix + '((bin 2) (oct 8) (hex 16))))) + ;; parse numbers similarly to calculators + ;; (see tests in test/lisp/calculator-tests.el) + (let ((str (replace-regexp-in-string "\\.\\([^0-9].*\\)?$" ".0\\1" str))) (float (string-to-number str))))) (defun calculator-push-curnum () diff --git a/test/lisp/calculator-tests.el b/test/lisp/calculator-tests.el new file mode 100644 index 0000000000..9551b1a4c6 --- /dev/null +++ b/test/lisp/calculator-tests.el @@ -0,0 +1,51 @@ +;;; calculator-tests.el --- Test suite for calculator. -*- lexical-binding: t -*- + +;; Copyright (C) 2021 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: +(require 'ert) +(require 'calculator) + +(ert-deftest calculator-test-calculator-string-to-number () + (dolist (x '(("" 0.0) + ("+" 0.0) + ("-" 0.0) + ("." 0.0) + ("+." 0.0) + ("-." -0.0) + (".-" 0.0) + ("--." 0.0) + ("-0.0e" -0.0) + ("1e1" 10.0) + ("1e+1" 10.0) + ("1e-1" 0.1) + ("+1e1" 10.0) + ("-1e1" -10.0) + ("+1e-1" 0.1) + ("-1e-1" -0.1) + (".1.e1" 0.1) + (".1..e1" 0.1) + ("1e+1.1" 10.0) + ("-2e-1.1" -0.2))) + (pcase x + (`(,str ,expected) + (let ((calculator-input-radix nil)) + (should (equal (calculator-string-to-number str) expected))))))) + +(provide 'calculator-tests) +;; calculator-tests.el ends here commit 01a513bf0beb9478e2ef801ca28ebc992455fe3c Author: Mattias Engdegård Date: Sun Apr 11 12:38:37 2021 +0200 Fix typo in cconv * lisp/emacs-lisp/cconv.el (cconv-convert): Typo. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test case. diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el index afaa13a869..b37cfebab3 100644 --- a/lisp/emacs-lisp/cconv.el +++ b/lisp/emacs-lisp/cconv.el @@ -498,7 +498,7 @@ places where they originally did not directly appear." (let* ((class (and var (cconv--var-classification (list var) form))) (newenv (cond ((eq class :captured+mutated) - (cons `(,var . (car-save ,var)) env)) + (cons `(,var . (car-safe ,var)) env)) ((assq var env) (cons `(,var) env)) (t env))) (msg (when (eq class :unused) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 94e33a7770..a11832d805 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -437,6 +437,13 @@ (/ 1 0) (arith-error x)))) (list x y)) + + (funcall + (condition-case x + (/ 1 0) + (arith-error (prog1 (lambda (y) (+ y x)) + (setq x 10)))) + 4) ) "List of expressions for cross-testing interpreted and compiled code.") commit 0334fa0532e63f22486b5142fa399decf54b18c0 Author: Philipp Stephani Date: Sun Apr 11 12:26:13 2021 +0200 Add another check for the required header . * configure.ac: Also check for . * src/emacs.c (SECCOMP_USABLE): Also check for . diff --git a/configure.ac b/configure.ac index be623c9654..cb4a9ab287 100644 --- a/configure.ac +++ b/configure.ac @@ -4181,7 +4181,7 @@ AC_SUBST([LIBS_MAIL]) HAVE_SECCOMP=no AC_CHECK_HEADERS( - [linux/seccomp.h], + [linux/seccomp.h linux/filter.h], [AC_CHECK_DECLS( [SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_TSYNC], [HAVE_SECCOMP=yes], [], diff --git a/src/emacs.c b/src/emacs.c index bd01d7bb46..694d975ec3 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -61,8 +61,8 @@ along with GNU Emacs. If not, see . */ # include #endif -#if defined HAVE_LINUX_SECCOMP_H \ - && HAVE_DECL_SECCOMP_SET_MODE_FILTER \ +#if defined HAVE_LINUX_SECCOMP_H && defined HAVE_LINUX_FILTER_H \ + && HAVE_DECL_SECCOMP_SET_MODE_FILTER \ && HAVE_DECL_SECCOMP_FILTER_FLAG_TSYNC # define SECCOMP_USABLE 1 #else commit 25937821bc445235d984c4db8cb18dfbacd6a4ff Author: Philipp Stephani Date: Sun Apr 11 12:00:35 2021 +0200 Also check for needed seccomp macros. It looks like these are not available on some versions of GNU/Linux, breaking the build. * configure.ac: Also check for needed seccomp macros. * src/emacs.c (SECCOMP_USABLE): New macro. (usage_message, main, standard_args): Use it. diff --git a/configure.ac b/configure.ac index 0c4772a2b9..be623c9654 100644 --- a/configure.ac +++ b/configure.ac @@ -4179,7 +4179,15 @@ fi AC_SUBST([BLESSMAIL_TARGET]) AC_SUBST([LIBS_MAIL]) -AC_CHECK_HEADERS([linux/seccomp.h], [HAVE_SECCOMP=yes]) +HAVE_SECCOMP=no +AC_CHECK_HEADERS( + [linux/seccomp.h], + [AC_CHECK_DECLS( + [SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_TSYNC], + [HAVE_SECCOMP=yes], [], + [[ + #include + ]])]) LIBSECCOMP= AC_CHECK_HEADER([seccomp.h], diff --git a/src/emacs.c b/src/emacs.c index 9d7b21cc76..bd01d7bb46 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -61,7 +61,15 @@ along with GNU Emacs. If not, see . */ # include #endif -#ifdef HAVE_LINUX_SECCOMP_H +#if defined HAVE_LINUX_SECCOMP_H \ + && HAVE_DECL_SECCOMP_SET_MODE_FILTER \ + && HAVE_DECL_SECCOMP_FILTER_FLAG_TSYNC +# define SECCOMP_USABLE 1 +#else +# define SECCOMP_USABLE 0 +#endif + +#if SECCOMP_USABLE # include # include # include @@ -248,7 +256,7 @@ Initialization options:\n\ --dump-file FILE read dumped state from FILE\n\ ", #endif -#ifdef HAVE_LINUX_SECCOMP_H +#if SECCOMP_USABLE "\ --sandbox=FILE read Seccomp BPF filter from FILE\n\ " @@ -950,7 +958,7 @@ load_pdump (int argc, char **argv) } #endif /* HAVE_PDUMPER */ -#ifdef HAVE_LINUX_SECCOMP_H +#if SECCOMP_USABLE /* Wrapper function for the `seccomp' system call on GNU/Linux. This system call usually doesn't have a wrapper function. See the @@ -1123,7 +1131,7 @@ maybe_load_seccomp (int argc, char **argv) fatal ("cannot enable seccomp filter from %s", file); } -#endif /* HAVE_LINUX_SECCOMP_H */ +#endif /* SECCOMP_USABLE */ int main (int argc, char **argv) @@ -1135,7 +1143,7 @@ main (int argc, char **argv) /* First, check whether we should apply a seccomp filter. This should come at the very beginning to allow the filter to protect the initialization phase. */ -#ifdef HAVE_LINUX_SECCOMP_H +#if SECCOMP_USABLE maybe_load_seccomp (argc, argv); #endif @@ -2333,7 +2341,7 @@ static const struct standard_args standard_args[] = #ifdef HAVE_PDUMPER { "-dump-file", "--dump-file", 1, 1 }, #endif -#ifdef HAVE_LINUX_SECCOMP_H +#if SECCOMP_USABLE { "-seccomp", "--seccomp", 1, 1 }, #endif #ifdef HAVE_NS commit 3cf9e2a6e33599bb12a949a3b5bd1847f39ab948 Author: Eli Zaretskii Date: Sun Apr 11 12:12:45 2021 +0300 Fix handling of mouse clicks on tab-bar buttons * src/xdisp.c (note_mouse_highlight): Don't attempt to highlight tab-bar buttons. (note_tab_bar_highlight): Function deleted: it had no effect on display of tab-bar buttons. (tab_bar_item_info): Mention all arguments in the commentary. (get_tab_bar_item): Don't pay attention to mouse-highlight information; instead, compare the button's index with the one recorded in f->last_tab_bar_item. (handle_tab_bar_click): Don't attempt to show tab-bar buttons in pressed or released state: that isn't supported. Determine whether to generate a tab-bar button click based on DOWN_P argument, not on mouse-highlight, which has no effect on tab-bar display. (Bug#47581) diff --git a/src/xdisp.c b/src/xdisp.c index a405d51f80..50d9040057 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13607,8 +13607,9 @@ redisplay_tab_bar (struct frame *f) /* Get information about the tab-bar item which is displayed in GLYPH on frame F. Return in *PROP_IDX the index where tab-bar item - properties start in F->tab_bar_items. Value is false if - GLYPH doesn't display a tab-bar item. */ + properties start in F->tab_bar_items. Return in CLOSE_P an + indication whether the click was on the close-tab icon of the tab. + Value is false if GLYPH doesn't display a tab-bar item. */ static bool tab_bar_item_info (struct frame *f, struct glyph *glyph, @@ -13654,7 +13655,6 @@ static int get_tab_bar_item (struct frame *f, int x, int y, struct glyph **glyph, int *hpos, int *vpos, int *prop_idx, bool *close_p) { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); struct window *w = XWINDOW (f->tab_bar_window); int area; @@ -13668,18 +13668,7 @@ get_tab_bar_item (struct frame *f, int x, int y, struct glyph **glyph, if (!tab_bar_item_info (f, *glyph, prop_idx, close_p)) return -1; - /* Is mouse on the highlighted item? */ - if (EQ (f->tab_bar_window, hlinfo->mouse_face_window) - && *vpos >= hlinfo->mouse_face_beg_row - && *vpos <= hlinfo->mouse_face_end_row - && (*vpos > hlinfo->mouse_face_beg_row - || *hpos >= hlinfo->mouse_face_beg_col) - && (*vpos < hlinfo->mouse_face_end_row - || *hpos < hlinfo->mouse_face_end_col - || hlinfo->mouse_face_past_end)) - return 0; - - return 1; + return *prop_idx == f->last_tab_bar_item ? 0 : 1; } @@ -13693,7 +13682,6 @@ void handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, int modifiers) { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); struct window *w = XWINDOW (f->tab_bar_window); int hpos, vpos, prop_idx; bool close_p; @@ -13701,47 +13689,27 @@ handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, Lisp_Object enabled_p; int ts; - /* If not on the highlighted tab-bar item, and mouse-highlight is - non-nil, return. This is so we generate the tab-bar button - click only when the mouse button is released on the same item as - where it was pressed. However, when mouse-highlight is disabled, - generate the click when the button is released regardless of the - highlight, since tab-bar items are not highlighted in that - case. */ frame_to_window_pixel_xy (w, &x, &y); ts = get_tab_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx, &close_p); if (ts == -1 - || (ts != 0 && !NILP (Vmouse_highlight))) + /* If the button is released on a tab other than the one where + it was pressed, don't generate the tab-bar button click event. */ + || (ts != 0 && !down_p)) return; - /* When mouse-highlight is off, generate the click for the item - where the button was pressed, disregarding where it was - released. */ - if (NILP (Vmouse_highlight) && !down_p) - prop_idx = f->last_tab_bar_item; - /* If item is disabled, do nothing. */ enabled_p = AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_ENABLED_P); if (NILP (enabled_p)) return; if (down_p) - { - /* Show item in pressed state. */ - if (!NILP (Vmouse_highlight)) - show_mouse_face (hlinfo, DRAW_IMAGE_SUNKEN); - f->last_tab_bar_item = prop_idx; - } + f->last_tab_bar_item = prop_idx; /* record the pressed tab */ else { Lisp_Object key, frame; struct input_event event; EVENT_INIT (event); - /* Show item in released state. */ - if (!NILP (Vmouse_highlight)) - show_mouse_face (hlinfo, DRAW_IMAGE_RAISED); - key = AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_KEY); XSETFRAME (frame, f); @@ -13754,97 +13722,6 @@ handle_tab_bar_click (struct frame *f, int x, int y, bool down_p, } } - -/* Possibly highlight a tab-bar item on frame F when mouse moves to - tab-bar window-relative coordinates X/Y. Called from - note_mouse_highlight. */ - -static void -note_tab_bar_highlight (struct frame *f, int x, int y) -{ - Lisp_Object window = f->tab_bar_window; - struct window *w = XWINDOW (window); - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); - int hpos, vpos; - struct glyph *glyph; - struct glyph_row *row; - int i; - Lisp_Object enabled_p; - int prop_idx; - bool close_p; - enum draw_glyphs_face draw = DRAW_IMAGE_RAISED; - int rc; - - /* Function note_mouse_highlight is called with negative X/Y - values when mouse moves outside of the frame. */ - if (x <= 0 || y <= 0) - { - clear_mouse_face (hlinfo); - return; - } - - rc = get_tab_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx, &close_p); - if (rc < 0) - { - /* Not on tab-bar item. */ - clear_mouse_face (hlinfo); - return; - } - else if (rc == 0) - /* On same tab-bar item as before. */ - goto set_help_echo; - - clear_mouse_face (hlinfo); - - bool mouse_down_p = false; -#ifndef HAVE_NS - /* Mouse is down, but on different tab-bar item? */ - Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f); - mouse_down_p = (gui_mouse_grabbed (dpyinfo) - && f == dpyinfo->last_mouse_frame); - - if (mouse_down_p && f->last_tab_bar_item != prop_idx) - return; -#endif - draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED; - - /* If tab-bar item is not enabled, don't highlight it. */ - enabled_p = AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_ENABLED_P); - if (!NILP (enabled_p) && !NILP (Vmouse_highlight)) - { - /* Compute the x-position of the glyph. In front and past the - image is a space. We include this in the highlighted area. */ - row = MATRIX_ROW (w->current_matrix, vpos); - for (i = x = 0; i < hpos; ++i) - x += row->glyphs[TEXT_AREA][i].pixel_width; - - /* Record this as the current active region. */ - hlinfo->mouse_face_beg_col = hpos; - hlinfo->mouse_face_beg_row = vpos; - hlinfo->mouse_face_beg_x = x; - hlinfo->mouse_face_past_end = false; - - hlinfo->mouse_face_end_col = hpos + 1; - hlinfo->mouse_face_end_row = vpos; - hlinfo->mouse_face_end_x = x + glyph->pixel_width; - hlinfo->mouse_face_window = window; - hlinfo->mouse_face_face_id = TAB_BAR_FACE_ID; - - /* Display it as active. */ - show_mouse_face (hlinfo, draw); - } - - set_help_echo: - - /* Set help_echo_string to a help string to display for this tab-bar item. - XTread_socket does the rest. */ - help_echo_object = help_echo_window = Qnil; - help_echo_pos = -1; - help_echo_string = AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_HELP); - if (NILP (help_echo_string)) - help_echo_string = AREF (f->tab_bar_items, prop_idx + TAB_BAR_ITEM_CAPTION); -} - #endif /* HAVE_WINDOW_SYSTEM */ /* Find the tab-bar item at X coordinate and return its information. */ @@ -33537,13 +33414,9 @@ note_mouse_highlight (struct frame *f, int x, int y) frame_to_window_pixel_xy (w, &x, &y); #if defined (HAVE_WINDOW_SYSTEM) - /* Handle tab-bar window differently since it doesn't display a - buffer. */ + /* We don't highlight tab-bar buttons. */ if (EQ (window, f->tab_bar_window)) - { - note_tab_bar_highlight (f, x, y); - return; - } + return; #endif #if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)