all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Christopher Thorne <c.thorne@reckondigital.com>, 34621@debbugs.gnu.org
Subject: bug#34621: Patch Update
Date: Tue, 5 Mar 2019 10:44:10 -0800 (PST)	[thread overview]
Message-ID: <40839b67-bce7-4a01-89f1-c14643b18b32@default> (raw)
In-Reply-To: <a566d740934418f15ccc286773c5ba17@reckondigital.com>

> > It doesn't sound to me like this has anything, per se,
> > to do with Dired.  It has to do with how the default is
> > determined, and that's apparently now being picked up
> > from the buffer name.
> 
> Hmm, I think you're right that this isn't just isolated to dired. For
> example, I can start a shell-mode buffer, rename it to shell.txt and
> rgrep will now suggest "*.txt" as the default extension even though my
> buffer is unrelated to .txt files.
> 
> An alternative I considered is only showing extension suggestions for
> buffers that are associated with a file (i.e. buffer-file-name is a
> non-empty string). Can you think of any cases where this would fall
> down?

I don't think it's a question of falling down.

It's not obvious what a reasonable or smart default
filename pattern is in most cases.  Just because
your current buffer is visiting a file does not at
all imply that you want to search files with the
same extension.

I think you need to (for yourself) specify just
what relation (if any) you want between the current
buffer and the default filename pattern.

If it's a question of improving `rgrep` then the
determination of the default needs to be such that
it's useful generally and typically, and perhaps
user configurable.

As an example, but for the search pattern only
(not the filename pattern(s)), in `grep+.el' there
is user option `grepp-default-regexp-fn` and a
default function of the same name, as follows.
(If the option value is not a function then the
default function is used.)

https://www.emacswiki.org/emacs/grep%2b.el

I mention this only as an example of how you can
provide some flexibility and user control.  For
filename pattern(s) obviously the ways of picking
a default would be different.

------------8<--------------

grepp-default-regexp-fn is a variable defined in `grep+.el'.
Its value is non-nil-symbol-name-nearest-point

Documentation:
Function of 0 args called to provide default search regexp to \\[grep].
Some reasonable choices are defined in `thingatpt+.el':
`word-nearest-point', `non-nil-symbol-name-nearest-point',
`region-or-non-nil-symbol-name-nearest-point', `sexp-nearest-point'.

This is ignored if Transient Mark mode is on and the region is active
and non-empty.  In that case, the quoted (") region text is used as
the default regexp.

If `grepp-default-regexp-fn' is nil and no prefix arg is given to
`grep', then no defaulting is done.

Otherwise, if the value is not a function, then function
`grepp-default-regexp-fn' does the defaulting.

You can customize this variable.

------------8<--------------

(defun grepp-default-regexp-fn ()
  "*Function of 0 args called to provide default search regexp to \\[grep].
This is used only if both of the following are true:
- Transient Mark mode is off or the region is inactive or empty.
- The value of option `grepp-default-regexp-fn' is
  `grepp-default-regexp-fn'.

When this is used, the default regexp is provided by calling the
first of these that references a defined function:
  - variable `grepp-default-regexp-fn'
  - variable `find-tag-default-function'
  - the `find-tag-default-function' property of the `major-mode'
  - function `non-nil-symbol-name-nearest-point', if bound
  - function `grep-tag-default'"
  (cond ((functionp grepp-default-regexp-fn) grepp-default-regexp-fn)
        (find-tag-default-function)
        ((get major-mode 'find-tag-default-function))
        ((fboundp 'non-nil-symbol-name-nearest-point) 'non-nil-symbol-name-nearest-point)
        (t 'find-tag-default)))





  reply	other threads:[~2019-03-05 18:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 17:29 bug#34621: [PATCH] lisp/progmodes/grep.el (grep-read-files): Add file-directory-p check Christopher Thorne
2019-03-04 11:13 ` bug#34621: Patch Update Christopher Thorne
2019-03-04 15:26   ` Drew Adams
2019-03-05 10:49     ` Christopher Thorne
2019-03-05 17:48       ` Drew Adams
2019-03-05 18:22         ` Christopher Thorne
2019-03-05 18:44           ` Drew Adams [this message]
2019-03-06 11:10             ` Christopher Thorne
2019-03-17 21:28               ` bug#34621: [PATCH] lisp/progmodes/grep.el (grep-read-files): Add file-directory-p check Juri Linkov
2019-04-08 10:41                 ` bug#34621: [PATCH] Fix rgrep in dired taking default search file pattern from directory name (e.g. *.11 for django-1.11) Christopher Thorne
2019-04-08 19:44                   ` Juri Linkov
2019-04-09 11:09                     ` Christopher Thorne
2019-04-09 11:52                       ` Noam Postavsky
2019-04-09 12:23                         ` Christopher Thorne
2019-04-09 14:18                           ` Eli Zaretskii
2019-04-09 14:32                             ` Christopher Thorne
2019-04-09 20:32                       ` Juri Linkov
2019-04-10 10:42                         ` Christopher Thorne
2019-04-10 20:37                           ` Juri Linkov
2019-04-11 20:51                             ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40839b67-bce7-4a01-89f1-c14643b18b32@default \
    --to=drew.adams@oracle.com \
    --cc=34621@debbugs.gnu.org \
    --cc=c.thorne@reckondigital.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.