commit bd6a19ccfdafa4e5a1c0d9028d2404bb55aec124 (HEAD, refs/remotes/origin/master) Author: Stefan Monnier Date: Thu Apr 11 21:06:59 2019 -0400 * lisp/vc/diff-mode.el: Avoid re-initializing buffer in diff-syntax (diff--syntax-file-attributes): New var. (diff-syntax-fontify-hunk): Detect when we're reusing the same buffer as last time, to avoid re-initializing it. Skip the diff-syntax-fontify-revisions hash-table, since buffer-alist plays the same role. (diff-syntax-fontify-revisions): Delete var. diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 8940c7e09a..1d5a2cf69a 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2411,10 +2411,11 @@ and the position in MAX." (diff-syntax-fontify-hunk beg end t) (diff-syntax-fontify-hunk beg end nil))) -(defvar diff-syntax-fontify-revisions (make-hash-table :test 'equal)) - (eval-when-compile (require 'subr-x)) ; for string-trim-right +(defvar-local diff--syntax-file-attributes nil) +(put 'diff--syntax-file-attributes 'permanent-local t) + (defun diff-syntax-fontify-hunk (beg end old) "Highlight source language syntax in diff hunk between BEG and END. When OLD is non-nil, highlight the hunk from the old source." @@ -2444,33 +2445,38 @@ When OLD is non-nil, highlight the hunk from the old source." (when file (if (not revision) ;; Get properties from the current working revision - (when (and (not old) (file-exists-p file) + (when (and (not old) (file-readable-p file) (file-regular-p file)) (let ((buf (get-file-buffer (expand-file-name file)))) ;; Try to reuse an existing buffer (if buf (with-current-buffer buf (diff-syntax-fontify-props nil text line-nb)) - ;; Get properties from the file - (with-temp-buffer - (insert-file-contents file) + ;; Get properties from the file. + (with-current-buffer (get-buffer-create + " *diff-syntax-file*") + (let ((attrs (file-attributes file))) + (if (equal diff--syntax-file-attributes attrs) + ;; Same file as last-time, unmodified. + ;; Reuse buffer as-is. + (setq file nil) + (insert-file-contents file) + (setq diff--syntax-file-attributes attrs))) (diff-syntax-fontify-props file text line-nb))))) ;; Get properties from a cached revision (let* ((buffer-name (format " *diff-syntax:%s.~%s~*" (expand-file-name file) revision)) - (buffer (gethash buffer-name - diff-syntax-fontify-revisions))) - (unless (and buffer (buffer-live-p buffer)) - (let* ((vc-buffer (ignore-errors - (vc-find-revision-no-save - (expand-file-name file) revision - diff-vc-backend - (get-buffer-create buffer-name))))) - (when vc-buffer - (setq buffer vc-buffer) - (puthash buffer-name buffer - diff-syntax-fontify-revisions)))) + (buffer (get-buffer buffer-name))) + (if buffer + ;; Don't re-initialize the buffer (which would throw + ;; away the previous fontification work). + (setq file nil) + (setq buffer (ignore-errors + (vc-find-revision-no-save + (expand-file-name file) revision + diff-vc-backend + (get-buffer-create buffer-name))))) (when buffer (with-current-buffer buffer (diff-syntax-fontify-props file text line-nb)))))))) commit 7ba7def5caf7ec9d9bebffff489f0a658229fbda Merge: 7768581172 de238b39e3 Author: Stephen Leake Date: Thu Apr 11 14:00:02 2019 -0700 Merge commit 'de238b39e335c6814283faa171b35145f124edf2' commit 7768581172e11be52b1fcd8224f4594e126bbdb7 Author: Stephen Leake Date: Thu Apr 11 13:58:36 2019 -0700 Make `next-error' output fewer messages about locus * lisp/simple.el (next-error-verbosity): New user variable. (next-error, next-error-internal): Use it to control only outputting locus message if locus changed. diff --git a/etc/NEWS b/etc/NEWS index 26c761ae01..3ad508aca3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -303,6 +303,10 @@ and directory-local variables. 'with-connection-local-profiles'. No argument 'profiles' needed any longer. +--- +** next-error-verbosity controls when `next-error' outputs a message + about the error locus. + * Editing Changes in Emacs 27.1 diff --git a/lisp/simple.el b/lisp/simple.el index 306df96766..be84e48cf4 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -110,6 +110,15 @@ If non-nil, the value is passed directly to `recenter'." :type 'hook :group 'next-error) +(defcustom next-error-verbosity nil + "If nil, `next-error' always outputs the current error buffer. +If non-nil, the message is output only when the error buffer +changes." + :group 'next-error + :type 'boolean + :safe #'booleanp + :version "27.1") + (defvar next-error-highlight-timer nil) (defvar next-error-overlay-arrow-position nil) @@ -312,21 +321,27 @@ To control which errors are matched, customize the variable ;; We know here that next-error-function is a valid symbol we can funcall (with-current-buffer buffer (funcall next-error-function (prefix-numeric-value arg) reset) - (next-error-found buffer (current-buffer)) - (message "%s locus from %s" - (cond (reset "First") - ((eq (prefix-numeric-value arg) 0) "Current") - ((< (prefix-numeric-value arg) 0) "Previous") - (t "Next")) - next-error-last-buffer))))) + (let ((prev next-error-last-buffer)) + (next-error-found buffer (current-buffer)) + (when (or (not next-error-verbosity) + (not (eq prev next-error-last-buffer))) + (message "%s locus from %s" + (cond (reset "First") + ((eq (prefix-numeric-value arg) 0) "Current") + ((< (prefix-numeric-value arg) 0) "Previous") + (t "Next")) + next-error-last-buffer))))))) (defun next-error-internal () "Visit the source code corresponding to the `next-error' message at point." (let ((buffer (current-buffer))) ;; We know here that next-error-function is a valid symbol we can funcall (funcall next-error-function 0 nil) - (next-error-found buffer (current-buffer)) - (message "Current locus from %s" next-error-last-buffer))) + (let ((prev next-error-last-buffer)) + (next-error-found buffer (current-buffer)) + (when (or (not next-error-verbosity) + (not (eq prev next-error-last-buffer))) + (message "Current locus from %s" next-error-last-buffer))))) (defun next-error-found (&optional from-buffer to-buffer) "Function to call when the next locus is found and displayed. commit de238b39e335c6814283faa171b35145f124edf2 Author: Christopher Thorne Date: Thu Apr 11 23:51:13 2019 +0300 Fix rgrep in dired using directory for search file pattern * lisp/progmodes/grep.el (grep-read-files): Allow major modes to define file name to use for default search pattern. Add non-directory file at point as default search pattern candidate. * lisp/dired.el (dired-grep-read-files): Use non-directory file at point for grep file name pattern. (Bug#34621) Copyright-paperwork-exempt: yes diff --git a/lisp/dired.el b/lisp/dired.el index 4c2c3f44e7..63082fe392 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -774,6 +774,15 @@ as an argument to `dired-goto-file'." (file-name-as-directory (abbreviate-file-name filename)) (abbreviate-file-name filename))))) +(defun dired-grep-read-files () + "Use file at point as the file for grep's default file-name pattern suggestion. +If a directory or nothing is found at point, return nil." + (let ((file-name (dired-file-name-at-point))) + (if (and file-name + (not (file-directory-p file-name))) + file-name))) +(put 'dired-mode 'grep-read-files 'dired-grep-read-files) + ;;;###autoload (define-key ctl-x-map "d" 'dired) ;;;###autoload (defun dired (dirname &optional switches) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index c0f47159c9..8c7a58fd8b 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -959,8 +959,16 @@ substitution string. Note dynamic scoping of variables.") The pattern can include shell wildcards. As whitespace triggers completion when entering a pattern, including it requires quoting, e.g. `\\[quoted-insert]'." - (let* ((bn (or (buffer-file-name) - (replace-regexp-in-string "<[0-9]+>\\'" "" (buffer-name)))) + (let* ((grep-read-files-function (get major-mode 'grep-read-files)) + (file-name-at-point + (run-hook-with-args-until-success 'file-name-at-point-functions)) + (bn (if grep-read-files-function + (funcall grep-read-files-function) + (or (if (and (stringp file-name-at-point) + (not (file-directory-p file-name-at-point))) + file-name-at-point) + (buffer-file-name) + (replace-regexp-in-string "<[0-9]+>\\'" "" (buffer-name))))) (fn (and bn (stringp bn) (file-name-nondirectory bn)))