unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* lgrep/rgrep not asking to save buffers
@ 2008-03-29 20:07 Tom Tromey
  2015-01-25 15:54 ` bug#96: " Hugh Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2008-03-29 20:07 UTC (permalink / raw)
  To: bug-gnu-emacs


Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:


I notice that lgrep and rgrep do not offer to save buffers.
This is different from other search and compilation commands.
This means that sometimes the results are incorrect.

Ideally these would only offer to save files that might actually be
matched by the command -- i.e., filtering buffers based on file
extension and directory.


If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
/usr/share/emacs/22.1/etc/DEBUG for instructions.


In GNU Emacs 22.1.1 (i386-redhat-linux-gnu, GTK+ Version 2.12.1)
 of 2007-11-06 on xenbuilder4.fedora.phx.redhat.com
Windowing system distributor `The X.Org Foundation', version 11.0.10300000
configured using `configure  '--build=i386-redhat-linux-gnu' '--host=i386-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-pop' '--with-sound' '--with-gtk' 'build_alias=i386-redhat-linux-gnu' 'host_alias=i386-redhat-linux-gnu' 'target_alias=i386-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -DSYSTEM_PURESIZE_EXTRA=16777216 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: C/l

Minor modes in effect:
  auto-fill-function: tjt-c++-do-auto-fill
  compilation-in-progress: (grep compilation compilation compilation compilation compilation grep gid compilation grep ...)
  shell-dirtrack-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-spelling-mode: t
  erc-truncate-mode: t
  flyspell-mode: t
  erc-status-mode: t
  erc-services-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-readonly-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
5 0 <return> M-> Q y n n SPC 5 0 <return> M-> C-u C-p 
C-n E S-SPC E S-SPC E SPC q n n SPC C-u E E E E E E 
E E E E E E q C-l M-< n n n l s SPC z C-c b C-z o C-a 
C-u C-u C-p C-u C-n C-p M-x g i d <return> <return> 
C-z o <f9> <f9> M-f M-f M-x g i <M-backspace> l g r 
e p <return> <return> <return> <return> C-x o C-x 1 
C-z o C-x 1 <f9> <f9> <f9> <f9> <f9> <f9> <f9> <f9> 
<f9> <switch-frame> <switch-frame> C-x b * g u <tab> 
<return> d e t <backspace> <backspace> <backspace> 
C-c C-c d e t a c h <return> q <return> C-c b <switch-frame> 
C-z o C-s C-g C-SPC C-g C-s C-w C-w C-s C-r C-r C-g 
C-z o C-c C-g C-z o M-f M-f M-f M-b c _ s m a M-/ SPC 
<backspace> <backspace> M-/ M-/ SPC ( C-e C-b ) C-a 
C-s c _ C-w C-s C-f C-f c _ s m a s M-/ SPC ( M-f ) 
C-s C-s C-s C-a C-s c _ a l i g n C-s C-x b <return> 
C-s a l i g n o f C-s C-s C-s C-x C-f c - c o m <tab> 
h <return> C-l C-a M-f M-f M-x g r e p <return> C-g 
M-x l g r e p <return> <return> <return> <return> <f9> 
C-h f l g r e p <return> C-h C-g <help-echo> <down-mouse-1> 
<mouse-2> C-x o C-x 1 C-c C-g C-g C-c b C-x s C-g M-x 
l g r e p <return> M-p <return> <return> <return> M-x 
r e p o r t - e m <tab> g <backspace> b <tab> <ret
urn>

Recent messages:
Saving /home/tromey/.newsrc.eld...done
(No files need saving)
Quit
Mark set
Quit [2 times]
Mark saved where search started [4 times]
Quit
Type C-x 1 to remove help window.  
Auto-saving...done
Quit
Quit
Tom




^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#96: lgrep/rgrep not asking to save buffers
  2008-03-29 20:07 lgrep/rgrep not asking to save buffers Tom Tromey
@ 2015-01-25 15:54 ` Hugh Brown
  2015-01-25 17:58   ` Eli Zaretskii
  2016-02-29  5:20   ` Lars Ingebrigtsen
  0 siblings, 2 replies; 4+ messages in thread
From: Hugh Brown @ 2015-01-25 15:54 UTC (permalink / raw)
  To: Tom Tromey; +Cc: 96

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]


Hi there -- I'm submitting a patch for this bug.  It applies cleanly
against the HEAD of the master branch right now
(f67446455fc0ec59f5c25c90a8783e571b60dc8f).

I'm following the directions in Lars Ingebrigtsen's "Welcome New Emacs
Developers" post, and copyright assignment is on file with the FSF (RT
#966206).  If you need anything else from me, please let me know.

Thanks,
Hugh


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch for bug #96 --]
[-- Type: text/x-diff, Size: 2559 bytes --]

diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 048fa11..27afc80 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -227,6 +227,28 @@ to determine whether cdr should not be excluded."
 		 (const :tag "No ignored files" nil))
   :group 'grep)
 
+;;;###autoload
+(defcustom grep-ask-about-save t
+  "Non-nil means \\[grep], \\[lgrep] and \\[rgrep] ask which buffers to save before running.
+Otherwise, it saves all modified buffers without asking."
+  :type 'boolean
+  :group 'grep)
+
+(defcustom grep-save-buffers-predicate nil
+  "The second argument (PRED) passed to `save-some-buffers' before compiling.
+E.g., one can set this to
+  (lambda ()
+    (string-prefix-p my-grep-root (file-truename (buffer-file-name))))
+to limit saving to files located under `my-grep-root'.
+Note, that, in general, `grep-directory' cannot be used instead
+of `my-grep-root' here."
+  :type '(choice
+          (const :tag "Default (save all file-visiting buffers)" nil)
+          (const :tag "Save all buffers" t)
+          function)
+  :group 'grep
+  :version "25.1")
+
 (defcustom grep-error-screen-columns nil
   "If non-nil, column numbers in grep hits are screen columns.
 See `compilation-error-screen-columns'"
@@ -753,6 +775,8 @@ list is empty)."
                                  'grep-history
                                  (if current-prefix-arg nil default))))))
 
+  (save-some-buffers (not grep-ask-about-save)
+		     grep-save-buffers-predicate)
   ;; Setting process-setup-function makes exit-message-function work
   ;; even when async processes aren't supported.
   (compilation-start (if (and grep-use-null-device null-device)
@@ -937,6 +961,8 @@ This command shares argument histories with \\[rgrep] and \\[grep]."
 	(let ((default-directory dir))
 	  ;; Setting process-setup-function makes exit-message-function work
 	  ;; even when async processes aren't supported.
+	  (save-some-buffers (not grep-ask-about-save)
+			     grep-save-buffers-predicate)
 	  (compilation-start (if (and grep-use-null-device null-device)
 				 (concat command " " null-device)
 			       command)
@@ -1050,6 +1076,8 @@ to specify a command to run."
 		    (read-from-minibuffer "Confirm: "
 					  command nil nil 'grep-find-history))
 	    (add-to-history 'grep-find-history command))
+	  (save-some-buffers (not grep-ask-about-save)
+			     grep-save-buffers-predicate)
 	  (let ((default-directory dir))
 	    (compilation-start command 'grep-mode))
 	  ;; Set default-directory if we started rgrep in the *grep* buffer.

[-- Attachment #3: Type: text/plain, Size: 131 bytes --]



-- 
Hugh Brown
aardvark@saintaardvarkthecarpeted.com
http://saintaardvarkthecarpeted.com
Because the plural of Anecdote is Myth.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#96: lgrep/rgrep not asking to save buffers
  2015-01-25 15:54 ` bug#96: " Hugh Brown
@ 2015-01-25 17:58   ` Eli Zaretskii
  2016-02-29  5:20   ` Lars Ingebrigtsen
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2015-01-25 17:58 UTC (permalink / raw)
  To: Hugh Brown; +Cc: tromey, 96

> From: Hugh Brown <aardvark@saintaardvarkthecarpeted.com>
> Date: Sun, 25 Jan 2015 07:54:07 -0800
> Cc: 96@debbugs.gnu.org
> 
> Hi there -- I'm submitting a patch for this bug.  It applies cleanly
> against the HEAD of the master branch right now
> (f67446455fc0ec59f5c25c90a8783e571b60dc8f).

Thanks.  Please provide a log entry for this.

> +(defcustom grep-ask-about-save t
> +  "Non-nil means \\[grep], \\[lgrep] and \\[rgrep] ask which buffers to save before running.
> +Otherwise, it saves all modified buffers without asking."
> +  :type 'boolean
> +  :group 'grep)

Is there a way to get back the current behavior, i.e. not save any
buffers?

In any case, this is a change in user-visible behavior, so I think it
warrants a NEWS entry

Also, this defcustom lacks a :version keyword.

> +(defcustom grep-save-buffers-predicate nil
> +  "The second argument (PRED) passed to `save-some-buffers' before compiling.
> +E.g., one can set this to
> +  (lambda ()
> +    (string-prefix-p my-grep-root (file-truename (buffer-file-name))))
> +to limit saving to files located under `my-grep-root'.

Did you consider letting grep-ask-about-save serve double duty, in
that it could also be a predicate function?  I'm not saying this would
necessarily be better, I'm just asking why not.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#96: lgrep/rgrep not asking to save buffers
  2015-01-25 15:54 ` bug#96: " Hugh Brown
  2015-01-25 17:58   ` Eli Zaretskii
@ 2016-02-29  5:20   ` Lars Ingebrigtsen
  1 sibling, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2016-02-29  5:20 UTC (permalink / raw)
  To: Hugh Brown; +Cc: Tom Tromey, 96

Hugh Brown <aardvark@saintaardvarkthecarpeted.com> writes:

> Hi there -- I'm submitting a patch for this bug.  It applies cleanly
> against the HEAD of the master branch right now
> (f67446455fc0ec59f5c25c90a8783e571b60dc8f).

Thanks; I've now applied it to the Emacs trunk (with the changes
suggested by Eli).  In particular, there's only one variable, and you
can set it to nil to make the grep commands not save anything.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-29  5:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-29 20:07 lgrep/rgrep not asking to save buffers Tom Tromey
2015-01-25 15:54 ` bug#96: " Hugh Brown
2015-01-25 17:58   ` Eli Zaretskii
2016-02-29  5:20   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).