commit bfd5e268a82d8ccbd758fdfbe445f9cb8b5befea (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Sat Sep 11 10:22:06 2021 +0300 ; * lisp/emacs-lisp/comp.el (native-comp-compiler-options): Doc fix. diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 92928e4ced..bb135457e2 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -169,7 +169,7 @@ if `confirm-kill-processes' is non-nil." (defcustom native-comp-compiler-options nil "Command line options passed verbatim to GCC compiler. Note that not all options are meaningful and some options might even -break your Emacs. Use at own risk. +break your Emacs. Use at your own risk. Passing these options is only available in libgccjit version 9 and above." commit ea3f0bcc786bb80e3fb8682e54c5f32336ac4986 Merge: 0b362912a4 74fd89fe17 Author: Eli Zaretskii Date: Sat Sep 11 10:18:21 2021 +0300 Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs commit 74fd89fe1747b14688aff1b61088551a5d261628 Author: Stefan Kangas Date: Sat Sep 11 09:15:46 2021 +0200 * lisp/info.el (Info-streamline-headings): Add entry. diff --git a/lisp/info.el b/lisp/info.el index 62202d342c..c09c75ad48 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -1455,6 +1455,7 @@ is non-nil)." (defvar Info-streamline-headings '(("Emacs" . "Emacs") ("Software development\\|Programming" . "Software development") + ("Compression\\|Data Compression" . "Compression") ("Libraries" . "Libraries") ("Network applications\\|World Wide Web\\|Net Utilities" . "Network applications")) commit 0b362912a41cb2a49ce14b55e47167f6e86954a5 Author: Eli Zaretskii Date: Sat Sep 11 10:16:59 2021 +0300 Improve documentation of Show Paren mode * doc/emacs/programs.texi (Matching): Improve wording and indexing. (Bug#29381) diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 522c092c3b..37a15b6d5f 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -809,42 +809,46 @@ displayed. The default is 102400. @cindex Show Paren mode @cindex highlighting matching parentheses @findex show-paren-mode - Show Paren mode, a global minor mode, provides a more powerful kind +@findex show-paren-local-mode + Show Paren mode is a minor mode that provides a more powerful kind of automatic matching. Whenever point is before an opening delimiter or after a closing delimiter, the delimiter, its matching delimiter, and optionally the text between them are highlighted. To toggle Show -Paren mode, type @kbd{M-x show-paren-mode}. To toggle it in single -buffer, type @kbd{M-x show-paren-local-mode}. To customize it, type -@kbd{M-x customize-group @key{RET} paren-showing}. The customizable -options which control the operation of this mode include: +Paren mode globally, type @kbd{M-x show-paren-mode}. To toggle it +only in the current buffer, type @kbd{M-x show-paren-local-mode}. To +customize it, type @w{@kbd{M-x customize-group @key{RET} paren-showing}}. +The customizable options which control the operation of this mode +include: @itemize @bullet @item @vindex show-paren-highlight-openparen @code{show-paren-highlight-openparen} controls whether to highlight -an open paren when point stands just before it, and hence its position +an open paren when point is just before it, and hence its position is marked by the cursor anyway. The default is non-@code{nil} (yes). @item @vindex show-paren-style @code{show-paren-style} controls whether just the two parens, or also -the space between them get highlighted. The valid options here are +the text between them get highlighted. The valid options here are @code{parenthesis} (show the matching paren), @code{expression} (highlight the entire expression enclosed by the parens), and -@code{mixed} (highlight the matching paren if it is visible, the -expression otherwise). +@code{mixed} (highlight the matching paren if it is visible in the +window, the expression otherwise). @item @vindex show-paren-when-point-inside-paren @code{show-paren-when-point-inside-paren}, when non-@code{nil}, causes -highlighting also when point is on the inside of a parenthesis. +highlighting also when point is inside of the parentheses. The +default is @code{nil}. @item @vindex show-paren-when-point-in-periphery @code{show-paren-when-point-in-periphery}, when non-@code{nil}, causes -highlighting also when point is in whitespace at the beginning or end -of a line, and there is a paren at, respectively, the first or last, -or the last, non-whitespace position on the line. +highlighting also when point is in whitespace at the beginning of a +line and there is a paren at the first or last non-whitespace position +on the line, or when point is at the end of a line and there is a +paren at the last non-whitespace position on the line. @end itemize @cindex Electric Pair mode commit f98700af80b37a43669955ec399ac300c3979384 Author: Eli Zaretskii Date: Sat Sep 11 09:56:27 2021 +0300 Fix restoring from pdumper file on MS-Windows 9X * src/pdumper.c (dump_map_file_w32): Use PAGE_WRITECOPY flag when calling CreateFileMapping for DUMP_MEMORY_ACCESS_READWRITE access, as that is required by Windows 9X. (Bug#50453) diff --git a/src/pdumper.c b/src/pdumper.c index 7730ea3d06..2291fced5d 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -4537,15 +4537,28 @@ dump_map_file_w32 (void *base, int fd, off_t offset, size_t size, uint32_t offset_low = (uint32_t) (full_offset & 0xffffffff); int error; + DWORD protect; DWORD map_access; file = (HANDLE) _get_osfhandle (fd); if (file == INVALID_HANDLE_VALUE) goto out; + switch (protection) + { + case DUMP_MEMORY_ACCESS_READWRITE: + protect = PAGE_WRITECOPY; /* for Windows 9X */ + break; + default: + case DUMP_MEMORY_ACCESS_NONE: + case DUMP_MEMORY_ACCESS_READ: + protect = PAGE_READONLY; + break; + } + section = CreateFileMapping (file, /*lpAttributes=*/NULL, - PAGE_READONLY, + protect, /*dwMaximumSizeHigh=*/0, /*dwMaximumSizeLow=*/0, /*lpName=*/NULL); commit d37dcfa30ff20aa2d5b0d6c2e43ef5930e72e375 Author: Dmitry Gutov Date: Sat Sep 11 05:11:53 2021 +0300 New minor mode 'show-paren-local-mode' * lisp/paren.el (show-paren--delete-overlays): New function, extracted from show-paren-mode. (show-paren-local-mode): New minor mode. (show-paren-mode): Update docstring to mention it (bug#29381). * doc/emacs/programs.texi (Matching): Update show-paren-mode section. diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index 09216c278b..522c092c3b 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -813,7 +813,8 @@ displayed. The default is 102400. of automatic matching. Whenever point is before an opening delimiter or after a closing delimiter, the delimiter, its matching delimiter, and optionally the text between them are highlighted. To toggle Show -Paren mode, type @kbd{M-x show-paren-mode}. To customize it, type +Paren mode, type @kbd{M-x show-paren-mode}. To toggle it in single +buffer, type @kbd{M-x show-paren-local-mode}. To customize it, type @kbd{M-x customize-group @key{RET} paren-showing}. The customizable options which control the operation of this mode include: diff --git a/etc/NEWS b/etc/NEWS index ea7bb6b10a..50cf0748b1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -983,6 +983,10 @@ achieve that. It used to be enabled when Emacs is started in GUI mode but not when started in text mode. The cursor still only actually blinks in GUI frames. +** New minor mode 'show-paren-local-mode'. +It serves as a local counterpart for 'show-paren-mode', allowing you +to toggle it separately in different buffers. + * Changes in Specialized Modes and Packages in Emacs 28.1 diff --git a/lisp/paren.el b/lisp/paren.el index a45a08abd3..708605f794 100644 --- a/lisp/paren.el +++ b/lisp/paren.el @@ -101,9 +101,11 @@ its position." (define-minor-mode show-paren-mode "Toggle visualization of matching parens (Show Paren mode). -Show Paren mode is a global minor mode. When enabled, any -matching parenthesis is highlighted in `show-paren-style' after -`show-paren-delay' seconds of Emacs idle time." +When enabled, any matching parenthesis is highlighted in `show-paren-style' +after `show-paren-delay' seconds of Emacs idle time. + +This is a global minor mode. To toggle the mode in a single buffer, +use `show-paren-local-mode'." :global t :group 'paren-showing ;; Enable or disable the mechanism. ;; First get rid of the old idle timer. @@ -114,8 +116,28 @@ matching parenthesis is highlighted in `show-paren-style' after show-paren-delay t #'show-paren-function)) (unless show-paren-mode - (delete-overlay show-paren--overlay) - (delete-overlay show-paren--overlay-1))) + (show-paren--delete-overlays))) + +(defun show-paren--delete-overlays () + (delete-overlay show-paren--overlay) + (delete-overlay show-paren--overlay-1)) + +;;;###autoload +(define-minor-mode show-paren-local-mode + "Toggle `show-paren-mode' only in this buffer." + :variable (buffer-local-value 'show-paren-mode (current-buffer)) + (cond + ((eq show-paren-mode (default-value 'show-paren-mode)) + (unless show-paren-mode + (show-paren--delete-overlays)) + (kill-local-variable 'show-paren-mode)) + ((not (default-value 'show-paren-mode)) + ;; Locally enabled, but globally disabled. + (show-paren-mode 1) ; Setup the timer. + (setq-default show-paren-mode nil) ; But keep it globally disabled. + ) + (t ;; Locally disabled only. + (show-paren--delete-overlays)))) (defun show-paren--unescaped-p (pos) "Determine whether the paren after POS is unescaped." commit 5c18d35acba751b2011d6746cf9c3c781e88db73 Author: Tassilo Horn Date: Sat Sep 11 00:04:46 2021 +0200 Improve overlay placement performance * lisp/progmodes/bug-reference.el (bug-reference--overlays-in): New function. (bug-reference-unfontify): Use it. (bug-reference-fontify): Reuse and move existing overlays instead of deleting all and creating them anew. diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index 33548344f3..586d4eed6c 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -105,21 +105,27 @@ highlighted, too." (bug-reference-set-overlay-properties) +(defun bug-reference--overlays-in (start end) + "Return bug reference overlays in the region between START and END." + (let (overlays) + (dolist (o (overlays-in start end)) + (when (eq (overlay-get o 'category) 'bug-reference) + (push o overlays))) + (nreverse overlays))) + (defun bug-reference-unfontify (start end) "Remove bug reference overlays from the region between START and END." - (dolist (o (overlays-in start end)) - (when (eq (overlay-get o 'category) 'bug-reference) - (delete-overlay o)))) + (mapc #'delete-overlay (bug-reference--overlays-in start end))) (defvar bug-reference-prog-mode) (defun bug-reference-fontify (start end) "Apply bug reference overlays to the region between START and END." (save-excursion - (let ((beg-line (progn (goto-char start) (line-beginning-position))) - (end-line (progn (goto-char end) (line-end-position)))) - ;; Remove old overlays. - (bug-reference-unfontify beg-line end-line) + (let* ((beg-line (progn (goto-char start) (line-beginning-position))) + (end-line (progn (goto-char end) (line-end-position))) + ;; Reuse existing overlays overlays. + (overlays (bug-reference--overlays-in beg-line end-line))) (goto-char beg-line) (while (and (< (point) end-line) (re-search-forward bug-reference-bug-regexp end-line 'move)) @@ -129,19 +135,28 @@ highlighted, too." ;; We highlight the 99th subexpression if that exists, ;; otherwise the complete match. See the docstring of ;; `bug-reference-bug-regexp'. - (let ((overlay (make-overlay (or (match-beginning 99) - (match-beginning 0)) - (or (match-end 99) - (match-end 0)) - nil t nil))) - (overlay-put overlay 'category 'bug-reference) - ;; Don't put a link if format is undefined + (let* ((s (or (match-beginning 99) + (match-beginning 0))) + (e (or (match-end 99) + (match-end 0))) + (overlay (or + (let ((ov (pop overlays))) + (when ov + (move-overlay ov s e) + ov)) + (let ((ov (make-overlay s e nil t nil))) + (overlay-put ov 'category 'bug-reference) + ov)))) + ;; Don't put a link if format is undefined. (when bug-reference-url-format (overlay-put overlay 'bug-reference-url (if (stringp bug-reference-url-format) (format bug-reference-url-format (match-string-no-properties 2)) - (funcall bug-reference-url-format)))))))))) + (funcall bug-reference-url-format))))))) + ;; Delete remaining but unused overlays. + (dolist (ov overlays) + (delete-overlay ov))))) ;; Taken from button.el. (defun bug-reference-push-button (&optional pos _use-mouse-action) commit dea67939b65f39b60d8e990745504bd8f9e3be2c Author: Arthur Miller Date: Fri Sep 10 20:57:19 2021 +0200 Add support for GCC compiler command-line options * lisp/emacs-lisp/comp.el ('native-comp-compiler-options): New option. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Add support for new 'native-comp-compiler-options'. * src/comp.c (Fcomp_native_compiler_options_effective_p): New function. (add_compiler_options): New function. (Fcomp__compile_ctxt_to_file): Call 'add_compiler_options'. diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 8ea591b5d0..47b3c82456 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2257,6 +2257,9 @@ With argument ARG, insert value in current buffer after the form." (push `(native-comp-speed . ,native-comp-speed) byte-native-qualities) (defvar native-comp-debug) (push `(native-comp-debug . ,native-comp-debug) byte-native-qualities) + (defvar native-comp-compiler-options) + (push `(native-comp-compiler-options . ,native-comp-compiler-options) + byte-native-qualities) (defvar native-comp-driver-options) (push `(native-comp-driver-options . ,native-comp-driver-options) byte-native-qualities) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 80a1da5ad8..92928e4ced 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -166,6 +166,16 @@ if `confirm-kill-processes' is non-nil." :type 'boolean :version "28.1") +(defcustom native-comp-compiler-options nil + "Command line options passed verbatim to GCC compiler. +Note that not all options are meaningful and some options might even +break your Emacs. Use at own risk. + +Passing these options is only available in libgccjit version 9 +and above." + :type '(repeat string) + :version "28.1") + (defcustom native-comp-driver-options nil "Options passed verbatim to the native compiler's back-end driver. Note that not all options are meaningful; typically only the options @@ -755,6 +765,8 @@ Returns ELT." :documentation "Default speed for this compilation unit.") (debug native-comp-debug :type number :documentation "Default debug level for this compilation unit.") + (compiler-options native-comp-compiler-options :type list + :documentation "Options for the GCC compiler.") (driver-options native-comp-driver-options :type list :documentation "Options for the GCC driver.") (top-level-forms () :type list @@ -1347,6 +1359,8 @@ clashes." byte-native-qualities) (comp-ctxt-debug comp-ctxt) (alist-get 'native-comp-debug byte-native-qualities) + (comp-ctxt-compiler-options comp-ctxt) (alist-get 'native-comp-compiler-options + byte-native-qualities) (comp-ctxt-driver-options comp-ctxt) (alist-get 'native-comp-driver-options byte-native-qualities) (comp-ctxt-top-level-forms comp-ctxt) @@ -3663,6 +3677,8 @@ Prepare every function for final compilation and drive the C back-end." comp-libgccjit-reproducer ,comp-libgccjit-reproducer comp-ctxt ,comp-ctxt native-comp-eln-load-path ',native-comp-eln-load-path + native-comp-compiler-options + ',native-comp-compiler-options native-comp-driver-options ',native-comp-driver-options load-path ',load-path) @@ -3926,6 +3942,8 @@ display a message." comp-libgccjit-reproducer ,comp-libgccjit-reproducer comp-async-compilation t native-comp-eln-load-path ',native-comp-eln-load-path + native-comp-compiler-options + ',native-comp-compiler-options native-comp-driver-options ',native-comp-driver-options load-path ',load-path diff --git a/src/comp.c b/src/comp.c index 7e21331e66..0012860096 100644 --- a/src/comp.c +++ b/src/comp.c @@ -515,6 +515,7 @@ typedef struct { typedef struct { EMACS_INT speed; EMACS_INT debug; + Lisp_Object compiler_options; Lisp_Object driver_options; gcc_jit_context *ctxt; gcc_jit_type *void_type; @@ -4383,6 +4384,22 @@ DEFUN ("comp-native-driver-options-effective-p", } #pragma GCC diagnostic pop +#pragma GCC diagnostic ignored "-Waddress" +DEFUN ("comp-native-compiler-options-effective-p", + Fcomp_native_compiler_options_effective_p, + Scomp_native_compiler_options_effective_p, + 0, 0, 0, + doc: /* Return t if `comp-native-compiler-options' is effective. */) + (void) +{ +#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option) + if (gcc_jit_context_add_command_line_option) + return Qt; +#endif + return Qnil; +} +#pragma GCC diagnostic pop + static void add_driver_options (void) { @@ -4422,6 +4439,43 @@ add_driver_options (void) #endif } +static void +add_compiler_options (void) +{ + Lisp_Object options = Fsymbol_value (Qnative_comp_compiler_options); + +#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option) + load_gccjit_if_necessary (true); + if (!NILP (Fcomp_native_compiler_options_effective_p ())) + FOR_EACH_TAIL (options) + gcc_jit_context_add_command_line_option (comp.ctxt, + /* FIXME: Need to encode + this, but how? either + ENCODE_FILE or + ENCODE_SYSTEM. */ + SSDATA (XCAR (options))); +#endif + if (CONSP (options)) + xsignal1 (Qnative_compiler_error, + build_string ("Customizing native compiler options" + " via `comp-native-compiler-options' is" + " only available on libgccjit version 9" + " and above.")); + + /* Captured `comp-native-compiler-options' because file-local. */ +#if defined (LIBGCCJIT_HAVE_gcc_jit_context_add_command_line_option) + options = comp.compiler_options; + if (!NILP (Fcomp_native_compiler_options_effective_p ())) + FOR_EACH_TAIL (options) + gcc_jit_context_add_command_line_option (comp.ctxt, + /* FIXME: Need to encode + this, but how? either + ENCODE_FILE or + ENCODE_SYSTEM. */ + SSDATA (XCAR (options))); +#endif +} + DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file, Scomp__compile_ctxt_to_file, 1, 1, 0, @@ -4467,6 +4521,7 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file, comp.debug = XFIXNUM (CALL1I (comp-ctxt-debug, Vcomp_ctxt)); eassert (comp.debug < INT_MAX); comp.driver_options = CALL1I (comp-ctxt-driver-options, Vcomp_ctxt); + comp.compiler_options = CALL1I (comp-ctxt-compiler-options, Vcomp_ctxt); if (comp.debug) gcc_jit_context_set_bool_option (comp.ctxt, @@ -4541,6 +4596,7 @@ DEFUN ("comp--compile-ctxt-to-file", Fcomp__compile_ctxt_to_file, "-fdisable-tree-isolate-paths"); #endif + add_compiler_options (); add_driver_options (); if (comp.debug > 1) @@ -5248,6 +5304,7 @@ compiled one. */); DEFSYM (Qnative_comp_speed, "native-comp-speed"); DEFSYM (Qnative_comp_debug, "native-comp-debug"); DEFSYM (Qnative_comp_driver_options, "native-comp-driver-options"); + DEFSYM (Qnative_comp_compiler_options, "native-comp-compiler-options"); DEFSYM (Qcomp_libgccjit_reproducer, "comp-libgccjit-reproducer"); /* Limple instruction set. */ @@ -5357,6 +5414,7 @@ compiled one. */); defsubr (&Scomp_el_to_eln_rel_filename); defsubr (&Scomp_el_to_eln_filename); defsubr (&Scomp_native_driver_options_effective_p); + defsubr (&Scomp_native_compiler_options_effective_p); defsubr (&Scomp__install_trampoline); defsubr (&Scomp__init_ctxt); defsubr (&Scomp__release_ctxt); commit 6eba633eadc4228f2b132cea257f1b32691fd6b2 Author: Dmitry Gutov Date: Fri Sep 10 18:42:55 2021 +0300 Fix test find-defs-defgeneric-el * test/lisp/progmodes/elisp-mode-tests.el (find-defs-defgeneric-el): Fix the test. Reported by dick.r.chiang@gmail.com. diff --git a/test/lisp/progmodes/elisp-mode-tests.el b/test/lisp/progmodes/elisp-mode-tests.el index f47d54e59c..2745aff670 100644 --- a/test/lisp/progmodes/elisp-mode-tests.el +++ b/test/lisp/progmodes/elisp-mode-tests.el @@ -604,6 +604,12 @@ to (xref-elisp-test-descr-to-target xref)." 'xref-location-marker nil '(xref-etags-location)) 'cl-defmethod (expand-file-name "../../../lisp/progmodes/etags.el" emacs-test-dir))) + (xref-make "(cl-defmethod xref-location-marker ((l xref-etags-apropos-location)))" + (xref-make-elisp-location + (cl--generic-load-hist-format + 'xref-location-marker nil '(xref-etags-apropos-location)) + 'cl-defmethod + (expand-file-name "../../../lisp/progmodes/etags.el" emacs-test-dir))) )) (xref-elisp-deftest find-defs-defgeneric-eval commit 192a384408cc846d8e66e91a67cd9ad4e7f0be24 Author: Lars Ingebrigtsen Date: Fri Sep 10 13:06:09 2021 +0200 Revert usage of format-prompt in python.el * lisp/progmodes/python.el (python-eldoc-at-point): Revert usage of format-prompt in python.el since this is also an ELPA package (and older Emacs versions doesn't have format-prompt). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 9434d26b7b..2eef52de0c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4739,7 +4739,9 @@ Interactively, prompt for symbol." (interactive (let ((symbol (python-eldoc--get-symbol-at-point)) (enable-recursive-minibuffers t)) - (list (read-string (format-prompt "Describe symbol" symbol) + (list (read-string (if symbol + (format "Describe symbol (default %s): " symbol) + "Describe symbol: ") nil nil symbol)))) (message (python-eldoc--get-doc-at-point symbol))) commit 195da78e2ee8ec27de9da7d2ba777313db31e4b7 Author: Augusto Stoffel Date: Fri Sep 10 13:04:54 2021 +0200 Properly encode all strings sent to Python shell * lisp/progmodes/python.el: Now depends on Emacs 28. (python-shell-package-enable, python-shell-completion-get-completions) (python-ffap-module-path, python-eldoc--get-doc-at-point): Enconde Python strings using 'python-shell--encode-string' instead of triple quotes. (python-shell-completion-string-code, python-eldoc-string-code) (python-ffap-string-code): Remove defcustoms. (bug#50503). diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e342ce7f56..9434d26b7b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2571,10 +2571,12 @@ the `buffer-name'." (format (concat "import os.path;import sys;" - "sys.path.append(os.path.dirname(os.path.dirname('''%s''')));" - "__package__ = '''%s''';" + "sys.path.append(os.path.dirname(os.path.dirname(%s)));" + "__package__ = %s;" "import %s") - directory package package) + (python-shell--encode-string directory) + (python-shell--encode-string package) + package) (python-shell-get-process))) (defun python-shell-accept-process-output (process &optional timeout regexp) @@ -3532,14 +3534,6 @@ def __PYTHON_EL_get_completions(text): "25.1" "Completion string code must work for (i)pdb.") -(defcustom python-shell-completion-string-code - "';'.join(__PYTHON_EL_get_completions('''%s'''))" - "Python code used to get a string of completions separated by semicolons. -The string passed to the function is the current python name or -the full statement in the case of imports." - :type 'string - :group 'python) - (defcustom python-shell-completion-native-disabled-interpreters ;; PyPy's readline cannot handle some escape sequences yet. Native ;; completion doesn't work on w32 (Bug#28580). @@ -3834,9 +3828,10 @@ completion." (python-util-strip-string (python-shell-send-string-no-output (format - (concat python-shell-completion-setup-code - "\nprint (" python-shell-completion-string-code ")") - input) process)))) + "%s\nprint(';'.join(__PYTHON_EL_get_completions(%s)))" + python-shell-completion-setup-code + (python-shell--encode-string input)) + process)))) (when (> (length completions) 2) (split-string completions "^'\\|^\"\\|;\\|'$\\|\"$" t))))) @@ -4559,28 +4554,16 @@ def __FFAP_get_module_path(objstr): :type 'string :group 'python) -(defcustom python-ffap-string-code - "__FFAP_get_module_path('''%s''')" - "Python code used to get a string with the path of a module." - :type 'string - :group 'python) - (defun python-ffap-module-path (module) "Function for `ffap-alist' to return path for MODULE." - (let ((process (or - (and (derived-mode-p 'inferior-python-mode) - (get-buffer-process (current-buffer))) - (python-shell-get-process)))) - (if (not process) - nil - (let ((module-file - (python-shell-send-string-no-output - (concat - python-ffap-setup-code - "\nprint (" (format python-ffap-string-code module) ")") - process))) - (unless (zerop (length module-file)) - (python-util-strip-string module-file)))))) + (when-let ((process (python-shell-get-process)) + (module-file + (python-shell-send-string-no-output + (format "%s\nprint(__FFAP_get_module_path(%s))" + python-ffap-setup-code + (python-shell--encode-string module))))) + (unless (string-empty-p module-file) + (python-util-strip-string module-file)))) (defvar ffap-alist) @@ -4671,12 +4654,6 @@ See `python-check-command' for the default." :type 'string :group 'python) -(defcustom python-eldoc-string-code - "__PYDOC_get_help('''%s''')" - "Python code used to get a string with the documentation of an object." - :type 'string - :group 'python) - (defun python-eldoc--get-symbol-at-point () "Get the current symbol for eldoc. Returns the current symbol handling point within arguments." @@ -4706,11 +4683,12 @@ returns will be used. If not FORCE-PROCESS is passed what ;; enabled. Bug#18794. (python-util-strip-string (python-shell-send-string-no-output - (concat + (format + "%s\nprint(__PYDOC_get_help(%s))" python-eldoc-setup-code - "\nprint(" (format python-eldoc-string-code input) ")") + (python-shell--encode-string input)) process))))) - (unless (zerop (length docstring)) + (unless (string-empty-p docstring) docstring))))) (defvar-local python-eldoc-get-doc t commit 5ee6583cb26801ba079e671071179482ccdd679a Author: Stephen Gildea Date: Fri Sep 10 06:30:06 2021 -0700 Tramp: honor default file modes in make-directory * lisp/net/tramp-sh.el: * lisp/net/tramp-adb.el: * lisp/net/tramp-sudoedit.el: * lisp/net/tramp-gvfs.el: Add support for default file modes to relevant Tramp back ends for make-directory. (Closes: Bug#50410) * test/lisp/net/tramp-tests.el (tramp-test13-make-directory-with-file-modes): New test. * etc/NEWS: Note this enhancement. Thanks to Michael Albinus for helping improve this patch. diff --git a/etc/NEWS b/etc/NEWS index 9031ae50b0..ea7bb6b10a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1955,7 +1955,7 @@ security key, like yubikey, solokey, or nitrokey. +++ *** Trashed remote files are moved to the local trash directory. -All remote files, which are trashed, are moved to the local trash +All remote files that are trashed are moved to the local trash directory, except remote encrypted files, which are always deleted. +++ @@ -1991,6 +1991,9 @@ Writing auto-save, backup or lock files to the local temporary directory must be confirmed. In order to suppress this confirmation, set user option 'tramp-allow-unsafe-temporary-files' to t. ++++ +*** 'make-directory' of a remote directory honors the default file modes. + ** gdb-mi *** New user option 'gdb-registers-enable-filter'. diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 70dbfdb947..a35ac37a20 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -442,7 +442,9 @@ Emacs dired can't find files." (make-directory par parents)))) (tramp-flush-directory-properties v localname) (unless (or (tramp-adb-send-command-and-check - v (format "mkdir %s" (tramp-shell-quote-argument localname))) + v (format "mkdir -m %#o %s" + (default-file-modes) + (tramp-shell-quote-argument localname))) (and parents (file-directory-p dir))) (tramp-error v 'file-error "Couldn't make directory %s" dir)))) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index e4f54cf4c4..eb889bb4f2 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -1574,10 +1574,13 @@ If FILE-SYSTEM is non-nil, return file system attributes." (when (and parents (not (file-directory-p ldir))) (make-directory ldir parents)) ;; Just do it. - (unless (or (tramp-gvfs-send-command - v "gvfs-mkdir" (tramp-gvfs-url-file-name dir)) - (and parents (file-directory-p dir))) - (tramp-error v 'file-error "Couldn't make directory %s" dir)))))) + (or (let ((mkdir-succeeded + (tramp-gvfs-send-command + v "gvfs-mkdir" (tramp-gvfs-url-file-name dir)))) + (if mkdir-succeeded (set-file-modes dir (default-file-modes))) + mkdir-succeeded) + (and parents (file-directory-p dir)) + (tramp-error v 'file-error "Couldn't make directory %s" dir)))))) (defun tramp-gvfs-handle-rename-file (filename newname &optional ok-if-already-exists) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index a2bf0afbf5..e57145e8e7 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2449,8 +2449,9 @@ The method used must be an out-of-band method." (tramp-flush-directory-properties v (if parents "/" (file-name-directory localname))) (tramp-barf-unless-okay - v (format "%s %s" + v (format "%s -m %#o %s" (if parents "mkdir -p" "mkdir") + (default-file-modes) (tramp-shell-quote-argument localname)) "Couldn't make directory %s" dir))) diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index 5895f1d25b..051d145c2a 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -597,6 +597,7 @@ the result will be a local, non-Tramp, file name." v (if parents "/" (file-name-directory localname))) (unless (tramp-sudoedit-send-command v (if parents '("mkdir" "-p") "mkdir") + "-m" (format "%#o" (default-file-modes)) (tramp-compat-file-name-unquote localname)) (tramp-error v 'file-error "Couldn't make directory %s" dir)))) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 54a585c88c..393302d7e1 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2765,28 +2765,38 @@ This checks also `file-name-as-directory', `file-name-directory', (ignore-errors (delete-directory source 'recursive)) (ignore-errors (delete-directory target 'recursive)))))))) -(ert-deftest tramp-test13-make-directory () - "Check `make-directory'. -This tests also `file-directory-p' and `file-accessible-directory-p'." - (skip-unless (tramp--test-enabled)) - - (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) +(defun tramp-test-make-directory-helper (test-default-file-modes-p) + "Helper test used by tramp-test13-make-directory* tests." + (dolist (quoted (if (and (tramp--test-expensive-test) + (not test-default-file-modes-p)) + '(nil t) + '(nil))) (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) - (tmp-name2 (expand-file-name "foo/bar" tmp-name1))) + (tmp-name2 (expand-file-name "foo/bar" tmp-name1)) + (unusual-file-mode-1 #o740) + (unusual-file-mode-2 #o710)) (unwind-protect (progn - (make-directory tmp-name1) + (with-file-modes unusual-file-mode-1 + (make-directory tmp-name1)) (should-error (make-directory tmp-name1) :type 'file-already-exists) (should (file-directory-p tmp-name1)) (should (file-accessible-directory-p tmp-name1)) + (and test-default-file-modes-p + (should (equal (format "%#o" unusual-file-mode-1) + (format "%#o" (file-modes tmp-name1))))) (should-error (make-directory tmp-name2) :type 'file-error) - (make-directory tmp-name2 'parents) + (with-file-modes unusual-file-mode-2 + (make-directory tmp-name2 'parents)) (should (file-directory-p tmp-name2)) (should (file-accessible-directory-p tmp-name2)) + (and test-default-file-modes-p + (should (equal (format "%#o" unusual-file-mode-2) + (format "%#o" (file-modes tmp-name2))))) ;; If PARENTS is non-nil, `make-directory' shall not ;; signal an error when DIR exists already. (make-directory tmp-name2 'parents)) @@ -2794,6 +2804,20 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." ;; Cleanup. (ignore-errors (delete-directory tmp-name1 'recursive)))))) +(ert-deftest tramp-test13-make-directory () + "Check `make-directory'. +This tests also `file-directory-p' and `file-accessible-directory-p'." + (skip-unless (tramp--test-enabled)) + (tramp-test-make-directory-helper nil)) + +(ert-deftest tramp-test13-make-directory-with-file-modes () + "Check that `make-directory' honors `default-file-modes'. +This is a separate test from `tramp-test13-make-directory' so +it can be skipped for backends that do not support file modes." + (skip-unless (tramp--test-enabled)) + (skip-unless (tramp--test-supports-file-modes-p)) + (tramp-test-make-directory-helper t)) + (ert-deftest tramp-test14-delete-directory () "Check `delete-directory'." (skip-unless (tramp--test-enabled)) @@ -3590,14 +3614,7 @@ They might differ only in time attributes or directory size." "Check `file-modes'. This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." (skip-unless (tramp--test-enabled)) - (skip-unless - (or (tramp--test-sh-p) (tramp--test-sshfs-p) (tramp--test-sudoedit-p) - ;; Not all tramp-gvfs.el methods support changing the file mode. - (and - (tramp--test-gvfs-p) - (string-match-p - "ftp" (file-remote-p tramp-test-temporary-file-directory 'method))))) - + (skip-unless (tramp--test-supports-file-modes-p)) (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) (let ((tmp-name1 (tramp--test-make-temp-name nil quoted)) (tmp-name2 (tramp--test-make-temp-name nil quoted))) @@ -6172,6 +6189,17 @@ This requires restrictions of file name syntax." This requires restrictions of file name syntax." (tramp-smb-file-name-p tramp-test-temporary-file-directory)) +(defun tramp--test-supports-file-modes-p () + "Return whether the method under test supports file modes." + ;; "smb" does not unless the SMB server supports "posix" extensions. + ;; "adb" does not unless the Android device is rooted. + (or (tramp--test-sh-p) (tramp--test-sshfs-p) (tramp--test-sudoedit-p) + ;; Not all tramp-gvfs.el methods support changing the file mode. + (and + (tramp--test-gvfs-p) + (string-match-p + "ftp" (file-remote-p tramp-test-temporary-file-directory 'method))))) + (defun tramp--test-check-files (&rest files) "Run a simple but comprehensive test over every file in FILES." ;; `filename-non-special' has been fixed in Emacs 27.1, see Bug#29579. commit f94b915e2f079eeaf3890bb08658f7c84dfc0773 Author: Eli Zaretskii Date: Fri Sep 10 15:02:41 2021 +0300 Doc string followup to last change. * lisp/progmodes/xref.el (xref-find-apropos): Mention 'tags-apropos-additional-actions' in the doc string. * lisp/progmodes/etags.el (tags-apropos-additional-actions): Mention 'xref-find-apropos' in the doc string. diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index 7efa88546d..cddf3ba0b9 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el @@ -158,11 +158,12 @@ Otherwise, `find-tag-default' is used." :version "21.1") (defcustom tags-apropos-additional-actions nil - "Specify additional actions for `tags-apropos'. + "Specify additional actions for `tags-apropos' and `xref-find-apropos'. If non-nil, value should be a list of triples (TITLE FUNCTION -TO-SEARCH). For each triple, `tags-apropos' processes TO-SEARCH and -lists tags from it. TO-SEARCH should be an alist, obarray, or symbol. +TO-SEARCH). For each triple, `tags-apropos' and `xref-find-apropos' +process TO-SEARCH and list tags from it. TO-SEARCH should be an alist, +obarray, or symbol. If it is a symbol, the symbol's value is used. TITLE, a string, is a title used to label the additional list of tags. FUNCTION is a function to call when a symbol is selected in the diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 082da1e1b7..9a0de5f449 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -1445,7 +1445,9 @@ This command is intended to be bound to a mouse event." ;;;###autoload (defun xref-find-apropos (pattern) "Find all meaningful symbols that match PATTERN. -The argument has the same meaning as in `apropos'." +The argument has the same meaning as in `apropos'. +See `tags-apropos-additional-actions' for how to augment the +output of this command when the backend is etags." (interactive (list (read-string "Search for pattern (word list or regexp): " nil 'xref--read-pattern-history commit b4158a75c0ae7d3318b958da8c75e0a07570effc Author: Eli Zaretskii Date: Fri Sep 10 14:57:38 2021 +0300 Document 'tags-apropos-additional-actions' with Xref * doc/emacs/maintaining.texi (Looking Up Identifiers): Rearrange and reword documentation of 'xref-find-apropos' and 'xref-auto-jump-to-first-definition'. Add the description of 'tags-apropos-additional-actions'. Delete the comment with not-yet implemented features that were available with 'tags-apropos'. * etc/NEWS: Augment the wording of 'xref-find-apropos' entry. diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 64221f19da..5a436a30fb 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -2141,31 +2141,15 @@ Switch @code{xref} to use the @code{etags} backend. @kindex M-. @findex xref-find-definitions @vindex xref-prompt-for-identifier - @kbd{M-.}@: (@code{xref-find-definitions}) shows the definitions of + @kbd{M-.}@: (@code{xref-find-definitions}) shows the definition of the identifier at point. With a prefix argument, or if there's no identifier at point, it prompts for the identifier. (If you want it to always prompt, customize @code{xref-prompt-for-identifier} to @code{t}.) -@vindex xref-auto-jump-to-first-definition -If the specified identifier has only one definition, the command jumps -to it. If the identifier has more than one possible definition (e.g., -in an object-oriented language, or if there's a function and a -variable by the same name), the command shows the candidate -definitions in the @file{*xref*} buffer, together with the files in -which these definitions are found. Selecting one of these candidates -by typing @kbd{@key{RET}} or clicking @kbd{mouse-2} will pop a buffer -showing the corresponding definition. If the value of the variable -@code{xref-auto-jump-to-first-definition} is @code{move}, the first -of these candidates is automatically selected, and if it's @code{t} or -@code{show}, the first candidate is automatically shown; @code{t} also -selects the window showing the first candidate. The default value is -@code{nil}, which just shows the candidates in the @file{*xref*} -buffer, but doesn't select any of them. - - When entering the identifier argument to @kbd{M-.}, the usual -minibuffer completion commands can be used (@pxref{Completion}), with -the known identifier names as completion candidates. + When entering the identifier argument to @kbd{M-.}, you can use the +usual minibuffer completion commands (@pxref{Completion}), with the +known identifier names being the completion candidates. @kindex C-x 4 . @findex xref-find-definitions-other-window @@ -2183,23 +2167,40 @@ former is @w{@kbd{C-x 4 .}} or around the place of a mouse event. This command is intended to be bound to a mouse event, such as @kbd{C-M-mouse-1}, for example. -@findex xref-find-apropos @kindex C-M-. - The command @kbd{C-M-.} (@code{xref-find-apropos}) finds the -definitions of one or more identifiers that match a specified regular -expression. It is just like @kbd{M-.} except that it does regexp +@findex xref-find-apropos +@vindex tags-apropos-additional-actions + The command @kbd{C-M-.}@: (@code{xref-find-apropos}) is like +@code{apropos} for tags (@pxref{Apropos}). It displays a list of +identifiers in the selected tags table whose names match the specified +@var{regexp}. This is just like @kbd{M-.}, except that it does regexp matching of identifiers instead of matching symbol names as fixed -strings. +strings. By default, the command pops up the @file{*xref*} buffer, +like @kbd{M-.}, but you can display additional output by customizing +the variable @code{tags-apropos-additional-actions}; see its +documentation for details. - When any of the above commands finds more than one definition, it -presents the @file{*xref*} buffer showing the definition candidates. -In that buffer, you have several specialized commands, described in -@ref{Xref Commands}. +@vindex xref-auto-jump-to-first-definition + If any of the above commands finds more than one matching +definition, it by default pops up the @file{*xref*} buffer showing the +matching candidates. (@kbd{C-M-.}@: @emph{always} pops up the +@file{*xref*} buffer if it finds at least one match.) The candidates +are normally shown in that buffer as the name of a file and the +matching identifier(s) in that file. In that buffer, you can select +any of the candidates for display, and you have several additional +commands, described in @ref{Xref Commands}. However, if the value of +the variable @code{xref-auto-jump-to-first-definition} is @code{move}, +the first of these candidates is automatically selected in the +@file{*xref*} buffer, and if it's @code{t} or @code{show}, the first +candidate is automatically shown in its own window; @code{t} also +selects the window showing the first candidate. The default value is +@code{nil}, which just shows the candidates in the @file{*xref*} +buffer, but doesn't select any of them. @kindex M-, @findex xref-pop-marker-stack @vindex xref-marker-ring-length - To go back to places @emph{from where} you found the definition, + To go back to places @emph{from where} you've displayed the definition, use @kbd{M-,} (@code{xref-pop-marker-stack}). It jumps back to the point of the last invocation of @kbd{M-.}. Thus you can find and examine the definition of something with @kbd{M-.} and then return to @@ -2410,15 +2411,14 @@ Searching}. Perform completion on the text around point, possibly using the selected tags table if one is loaded (@code{completion-at-point}). -@item M-x xref-find-apropos @key{RET} @var{regexp} @key{RET} -Display a list of all known identifiers matching @var{regexp}. -The way this command displays the matches is affected by the value of -@code{xref-auto-jump-to-first-xref} (@pxref{Identifier Search}). - @item M-x list-tags @key{RET} @var{file} @key{RET} Display a list of the identifiers defined in the program file @var{file}. +@item C-M-. @var{regexp} @key{RET} +Display a list of all identifiers matching @var{regexp} +(@code{xref-find-apropos}). @xref{Looking Up Identifiers}. + @item M-x tags-next-file Visit files recorded in the selected tags table. @end table @@ -2440,25 +2440,6 @@ for the project to be available. @xref{Tags Tables}. If used interactively, the default tag is file name of the current buffer if used interactively. -@c Sadly, the new-and-improved Xref feature doesn't provide some -@c of the features of the now-obsoleted tags-apropos. I'm leaving -@c this here to encourage enhancements to xref.el. -@ignore -@findex tags-apropos -@vindex tags-apropos-verbose -@vindex tags-tag-face -@vindex tags-apropos-additional-actions - @kbd{M-x tags-apropos} is like @code{apropos} for tags -(@pxref{Apropos}). It displays a list of tags in the selected tags -table whose entries match @var{regexp}. If the variable -@code{tags-apropos-verbose} is non-@code{nil}, it displays the names -of the tags files together with the tag names. You can customize the -appearance of the output by setting the variable @code{tags-tag-face} -to a face. You can display additional output by customizing the -variable @code{tags-apropos-additional-actions}; see its documentation -for details. -@end ignore - @findex tags-next-file @kbd{M-x tags-next-file} visits files covered by the selected tags table. The first time it is called, it visits the first file covered by the diff --git a/etc/NEWS b/etc/NEWS index e8dde4555c..9031ae50b0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2401,7 +2401,9 @@ When non-nil, matches for identifiers in the file visited by the current buffer will be shown first in the "*xref*" buffer. *** The etags Xref backend now honors 'tags-apropos-additional-actions'. -You can customize it to augment the output of 'xref-find-apropos'. +You can customize it to augment the output of 'xref-find-apropos', +like it affected the output of 'tags-apropos', which is obsolete since +Emacs 25.1. ** Battery commit 28ce3bf5c92d36230613036dddd2a055777b3738 Author: Lars Ingebrigtsen Date: Fri Sep 10 12:56:22 2021 +0200 Further fix for the search-whitespace-regexp change * lisp/isearch.el (search-whitespace-regexp): Fix yet another typo in this one-line change (bug#21278). diff --git a/lisp/isearch.el b/lisp/isearch.el index 8a79fd5a26..efa7db6fe9 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -114,7 +114,7 @@ is called to let you enter the search string, and RET terminates editing and does a nonincremental search.)" :type 'boolean) -(defcustom search-whitespace-regexp (purecopy "[ \t]") +(defcustom search-whitespace-regexp (purecopy "[ \t]+") "If non-nil, regular expression to match a sequence of whitespace chars. When you enter a space or spaces in the incremental search, it will match any sequence matched by this regexp. As an exception, commit f3cfd478980749d18d7fbc7be941a1e8bc145c5f Author: Gregory Heytings Date: Fri Sep 10 12:43:45 2021 +0200 New user options to move between isearch matches * lisp/isearch.el (isearch-allow-motion, isearch-motion-changes-direction): New user options. (isearch-pre-command-hook): Handle the new options. * etc/NEWS: Mention the new user options. * doc/emacs/search.texi: Document the new user options. diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi index a1760ad66f..e4322e361f 100644 --- a/doc/emacs/search.texi +++ b/doc/emacs/search.texi @@ -593,6 +593,19 @@ or the selected window and frame. The command must not itself attempt an incremental search. This feature is disabled if @code{isearch-allow-scroll} is @code{nil} (which it is by default). +@vindex isearch-allow-motion +@vindex isearch-motion-changes-direction + Likewise, if you change the variable @code{isearch-allow-motion} +to a non-@code{nil} value, this enables the use of the keyboard motion +commands @kbd{M-<}, @kbd{M->}, @kbd{C-v} and @kbd{M-v}, to move +respectively to the first occurrence of the current search string in +the buffer, the last one, the first one after the current window, +and the last one before the current window. The search direction +does not change when these motion commands are used, unless you change +the variable @code{isearch-motion-changes-direction} to a non-@code{nil} +value, in which case the search direction is forward after @kbd{M-<} and +@kbd{C-v}, and backward after @kbd{M->} and @kbd{M-v}. + @item Motion Commands @cindex motion commands, during incremental search When @code{isearch-yank-on-move} is customized to @code{shift}, diff --git a/etc/NEWS b/etc/NEWS index 01eb2a5611..e8dde4555c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1132,6 +1132,18 @@ keys, add the following to your init file: Using it instead of 'read-char-choice' allows using 'C-x o' to switch to the help window displayed after typing 'C-h'. ++++ +** New user option 'isearch-allow-motion'. +When 'isearch-allow-motion' is set, the commands 'beginning-of-buffer', +'end-of-buffer', 'scroll-up-command' and 'scroll-down-command', when +invoked during I-search, move respectively to the first occurrence of +the current search string in the buffer, the last one, the first one +after the current window, and the last one before the current window. +Additionally, users can change the meaning of other motion commands +during I-search by using their 'isearch-motion' property. The +option 'isearch-motion-changes-direction' controls whether the +direction of the search changes after a motion command. + ** Outline +++ diff --git a/lisp/isearch.el b/lisp/isearch.el index 133c604bb3..8a79fd5a26 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2927,12 +2927,49 @@ If non-nil, scrolling commands can be used in Isearch mode. However, you cannot scroll far enough that the current match is no longer visible (is off screen). But if the value is `unlimited' that limitation is removed and you can scroll any distance off screen. -If nil, scrolling commands exit Isearch mode." +If nil, scrolling commands exit Isearch mode. +See also the related option `isearch-allow-motion'." :type '(choice (const :tag "Scrolling exits Isearch" nil) (const :tag "Scrolling with current match on screen" t) (const :tag "Scrolling with current match off screen" unlimited)) :group 'isearch) +(put 'beginning-of-buffer 'isearch-motion + '((lambda () (goto-char (point-min))) . forward)) +(put 'end-of-buffer 'isearch-motion + '((lambda () (goto-char (point-max))) . backward)) +(put 'scroll-up-command 'isearch-motion + '((lambda () (goto-char (window-end)) (recenter 1 t)) . forward)) +(put 'scroll-down-command 'isearch-motion + '((lambda () (goto-char (window-start)) (recenter -1 t)) . backward)) + +(defcustom isearch-allow-motion nil + "Whether to allow movement between isearch matches by cursor motion commands. +If non-nil, the four motion commands \\[beginning-of-buffer], \\[end-of-buffer], \ +\\[scroll-up-command] and \\[scroll-down-command], when invoked during +Isearch, move respectively to the first occurrence of the current search string +in the buffer, the last one, the first one after the current window, and the +last one before the current window. +If nil, these motion commands normally exit Isearch and are executed. +See also the related options `isearch-motion-changes-direction' and +`isearch-allow-scroll'." + :type '(choice (const :tag "Off" nil) + (const :tag "On" t)) + :group 'isearch + :version "28.1") + +(defcustom isearch-motion-changes-direction nil + "Whether motion commands during incremental search change search direction. +If nil, the search direction (forward or backward) does not change when +motion commands are used during incremental search, except when wrapping. +If non-nil, the search direction is forward after \\[beginning-of-buffer] and \ +\\[scroll-up-command], and +backward after \\[end-of-buffer] and \\[scroll-down-command]." + :type '(choice (const :tag "Off" nil) + (const :tag "On" t)) + :group 'isearch + :version "28.1") + (defcustom isearch-allow-prefix t "Whether prefix arguments are allowed during incremental search. If non-nil, entering a prefix argument will not terminate the @@ -3034,6 +3071,24 @@ See more for options in `search-exit-option'." ;; Optionally edit the search string instead of exiting. ((eq search-exit-option 'edit) (setq this-command 'isearch-edit-string)) + ;; Handle motion command functions. + ((and isearch-allow-motion + (symbolp this-command) + (get this-command 'isearch-motion)) + (let* ((property (get this-command 'isearch-motion)) + (function (car property)) + (current-direction (if isearch-forward 'forward 'backward)) + (direction (or (cdr property) + (if isearch-forward 'forward 'backward)))) + (funcall function) + (setq isearch-just-started t) + (let ((isearch-repeat-on-direction-change nil)) + (isearch-repeat direction)) + (when (and isearch-success (not isearch-motion-changes-direction)) + (unless (eq direction current-direction) + (let ((isearch-repeat-on-direction-change nil)) + (isearch-repeat current-direction)))) + (setq this-command 'ignore))) ;; Handle a scrolling function or prefix argument. ((or (and isearch-allow-prefix (memq this-command '(universal-argument universal-argument-more commit 150ff9c1575b4260ca603bf0981e8612e4ea5687 Author: Lars Ingebrigtsen Date: Fri Sep 10 12:42:22 2021 +0200 Fix typo in previous search-whitespace-regexp change * lisp/isearch.el (search-whitespace-regexp): Fix typo in last checkin for this variable. diff --git a/lisp/isearch.el b/lisp/isearch.el index 357760caee..133c604bb3 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -114,7 +114,7 @@ is called to let you enter the search string, and RET terminates editing and does a nonincremental search.)" :type 'boolean) -(defcustom search-whitespace-regexpx (purecopy "[ \t]") +(defcustom search-whitespace-regexp (purecopy "[ \t]") "If non-nil, regular expression to match a sequence of whitespace chars. When you enter a space or spaces in the incremental search, it will match any sequence matched by this regexp. As an exception, commit 061f8f28000e39f6ec4194ec2face3eb6e880846 Author: Gregory Heytings Date: Fri Sep 10 12:39:33 2021 +0200 Fix behavior of isearch-{beginning,end}-of-buffer * lisp/isearch.el (isearch-beginning-of-buffer) (isearch-end-of-buffer): Fix their behavior when isearch-repeat-on-direction-change is non-nil (bug#50466). diff --git a/lisp/isearch.el b/lisp/isearch.el index 71c9ce31de..357760caee 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -114,7 +114,7 @@ is called to let you enter the search string, and RET terminates editing and does a nonincremental search.)" :type 'boolean) -(defcustom search-whitespace-regexp (purecopy "[ \t]") +(defcustom search-whitespace-regexpx (purecopy "[ \t]") "If non-nil, regular expression to match a sequence of whitespace chars. When you enter a space or spaces in the incremental search, it will match any sequence matched by this regexp. As an exception, @@ -2009,7 +2009,8 @@ type \\[isearch-repeat-forward] with a numeric argument." ;; don't forward char in isearch-repeat (setq isearch-just-started t) (goto-char (point-min)) - (isearch-repeat 'forward arg))) + (let ((isearch-repeat-on-direction-change nil)) + (isearch-repeat 'forward arg)))) (defun isearch-end-of-buffer (&optional arg) "Go to the last occurrence of the current search string. @@ -2023,7 +2024,8 @@ type \\[isearch-repeat-backward] with a numeric argument." (isearch-beginning-of-buffer (abs arg)) (setq isearch-just-started t) (goto-char (point-max)) - (isearch-repeat 'backward arg))) + (let ((isearch-repeat-on-direction-change nil)) + (isearch-repeat 'backward arg)))) ;;; Toggles for `isearch-regexp-function' and `search-default-mode'. commit 74d091a0a665da5dc01989d1b06a61ee21b975b2 Author: Lars Ingebrigtsen Date: Fri Sep 10 12:27:28 2021 +0200 Change the default value of search-whitespace-regexp * lisp/isearch.el (search-whitespace-regexp): Change the default to always exclude newlines from the set (bug#21278). It used to be mode-dependent whether newlines were included or not, and this was confusing as a user interface. diff --git a/etc/NEWS b/etc/NEWS index 8f20db7a76..01eb2a5611 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1031,6 +1031,12 @@ search string is at least this long. 'lazy-highlight-initial-delay' still applies for shorter search strings, which avoids flicker in the search buffer due to too many matches being highlighted. +--- +*** The default 'search-whitespace-regexp' value has changed. +This used to be "\\s-+", which meant that it was mode-dependent whether +newlines were included in the whitespace set. This has now been +changed to only match spaces and tab characters. + ** Dired +++ diff --git a/lisp/isearch.el b/lisp/isearch.el index 1c776a06e1..71c9ce31de 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -114,7 +114,7 @@ is called to let you enter the search string, and RET terminates editing and does a nonincremental search.)" :type 'boolean) -(defcustom search-whitespace-regexp (purecopy "\\s-+") +(defcustom search-whitespace-regexp (purecopy "[ \t]") "If non-nil, regular expression to match a sequence of whitespace chars. When you enter a space or spaces in the incremental search, it will match any sequence matched by this regexp. As an exception, @@ -134,7 +134,7 @@ add any capturing groups into this value; that can change the numbering of existing capture groups in unexpected ways." :type '(choice (const :tag "Match Spaces Literally" nil) regexp) - :version "24.3") + :version "28.1") (defcustom search-invisible 'open "If t incremental search/query-replace can match hidden text.