GNU bug report logs - #14405
24.3.50; read-regexp-defaults-function

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> jurta.org>

Date: Wed, 15 May 2013 00:02:01 UTC

Severity: wishlist

Found in version 24.3.50

Done: Juri Linkov <juri <at> jurta.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14405 in the body.
You can then email your comments to 14405 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Wed, 15 May 2013 00:02:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 15 May 2013 00:02:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; read-regexp-defaults-function
Date: Wed, 15 May 2013 02:51:20 +0300
This is a continuation from bug#13892 and bug#13687
closed and archived two months ago.  As the unfinished
discussion indicates there are pending enhancements
to create a single option to define the same defaulting
behavior for all regexp-reading commands and to group
the existing defaults to separate functions that can be
overridden by customizing that option.

This is a preliminary implementation:

=== modified file 'lisp/replace.el'
--- lisp/replace.el	2013-04-22 04:17:30 +0000
+++ lisp/replace.el	2013-05-14 23:50:29 +0000
@@ -580,6 +580,41 @@ (defvar regexp-history nil
 (defvar occur-collect-regexp-history '("\\1")
   "History of regexp for occur's collect operation")
 
+(defcustom read-regexp-defaults-function nil
+  "Function that provides default regexp(s) for regexp reading commands.
+This function should take no arguments and return one of nil, a
+regexp or a list of regexps.  The return value of this function is used
+as DEFAULTS param of `read-regexp'.  This function is called only during
+interactive use.
+
+You can customize `read-regexp-defaults-function' to the value
+`find-tag-default-as-regexp' to highlight a symbol at point."
+  :type '(choice
+          (const :tag "No default regexp reading function" nil)
+          (choice :tag "Function to provide default for read-regexp"
+		  (function-item :tag "Tag at point" find-tag-default)
+		  (function-item :tag "Symbol at point" find-tag-default-as-regexp)
+		  (function-item :tag "Latest history" (lambda () (car regexp-history)))
+		  function))
+  :group 'matching
+  :version "24.4")
+
+(defun read-regexp-defaults ()
+  (if (functionp read-regexp-defaults-function)
+      (funcall read-regexp-defaults-function)))
+
+(defun read-regexp-defaults-history ()
+  "Return the latest regexp from `regexp-history'.
+See `read-regexp-defaults-function' for details."
+  (or (read-regexp-defaults)
+      (car regexp-history)))
+
+(defun read-regexp-defaults-tag ()
+  "Return the regexp that matches the default tag at point.
+See `read-regexp-defaults-function' for details."
+  (or (read-regexp-defaults)
+      (find-tag-default-as-regexp)))
+
 (defun read-regexp (prompt &optional defaults history)
   "Read and return a regular expression as a string.
 When PROMPT doesn't end with a colon and space, it adds a final \": \".
@@ -636,7 +671,7 @@ (defun keep-lines-read-args (prompt)
   "Read arguments for `keep-lines' and friends.
 Prompt for a regexp with PROMPT.
 Value is a list, (REGEXP)."
-  (list (read-regexp prompt) nil nil t))
+  (list (read-regexp prompt (read-regexp-defaults-history)) nil nil t))
 
 (defun keep-lines (regexp &optional rstart rend interactive)
   "Delete all lines except those containing matches for REGEXP.
@@ -1143,32 +1178,35 @@ (defcustom occur-excluded-properties
   :group 'matching
   :version "22.1")
 
-(defvar occur-read-regexp-defaults-function
-  'occur-read-regexp-defaults
+(defun occur-read-regexp-defaults ()
   "Function that provides default regexp(s) for occur commands.
-This function should take no arguments and return one of nil, a
+This function takes no arguments and returns one of nil, a
 regexp or a list of regexps for use with occur commands -
 `occur', `multi-occur' and `multi-occur-in-matching-buffers'.
 The return value of this function is used as DEFAULTS param of
 `read-regexp' while executing the occur command.  This function
 is called only during interactive use.
 
-For example, to check for occurrence of symbol at point use
-
-    \(setq occur-read-regexp-defaults-function
-	  'find-tag-default-as-regexp\).")
-
-(defun occur-read-regexp-defaults ()
-  "Return the latest regexp from `regexp-history'.
-See `occur-read-regexp-defaults-function' for details."
-  (car regexp-history))
+You can customize `read-regexp-defaults-function' to the value
+`find-tag-default-as-regexp' to highlight a symbol at point."
+  (read-regexp-defaults-history))
+
+(defun occur-collect-read-regexp-defaults ()
+  "Return the latest regexp from `occur-collect-regexp-history'.
+This function is used to read a regexp to collect.
+See `read-regexp-defaults-function' for details.
+
+You can customize `read-regexp-defaults-function' to the value
+`find-tag-default-as-regexp' to highlight a symbol at point."
+  (or (read-regexp-defaults)
+      (car occur-collect-regexp-history)))
 
 (defun occur-read-primary-args ()
   (let* ((perform-collect (consp current-prefix-arg))
          (regexp (read-regexp (if perform-collect
                                   "Collect strings matching regexp"
                                 "List lines matching regexp")
-                              (funcall occur-read-regexp-defaults-function))))
+                              (occur-read-regexp-defaults))))
     (list regexp
 	  (if perform-collect
 	      ;; Perform collect operation
@@ -1176,7 +1214,7 @@ (defun occur-read-primary-args ()
 		  ;; No subexpression so collect the entire match.
 		  "\\&"
 		;; Get the regexp for collection pattern.
-		(let ((default (car occur-collect-regexp-history)))
+		(let ((default (occur-collect-read-regexp-defaults)))
 		  (read-regexp
 		   (format "Regexp to collect (default %s): " default)
 		   default 'occur-collect-regexp-history)))

=== modified file 'lisp/hi-lock.el'
--- lisp/hi-lock.el	2013-04-22 04:17:30 +0000
+++ lisp/hi-lock.el	2013-05-14 23:50:37 +0000
@@ -279,26 +279,6 @@ (defvar hi-lock-map
     map)
   "Key map for hi-lock.")
 
-(defvar hi-lock-read-regexp-defaults-function
-  'hi-lock-read-regexp-defaults
-  "Function that provides default regexp(s) for highlighting commands.
-This function should take no arguments and return one of nil, a
-regexp or a list of regexps for use with highlighting commands -
-`hi-lock-face-phrase-buffer', `hi-lock-line-face-buffer' and
-`hi-lock-face-buffer'.  The return value of this function is used
-as DEFAULTS param of `read-regexp' while executing the
-highlighting command.  This function is called only during
-interactive use.  
-
-For example, to highlight at symbol at point use
-
-    \(setq hi-lock-read-regexp-defaults-function 
-	  'find-tag-default-as-regexp\)
-
-If you need different defaults for different highlighting
-operations, use `this-command' to identify the command under
-execution.")
-
 ;; Visible Functions
 
 ;;;###autoload
@@ -422,7 +402,7 @@ (defalias 'highlight-lines-matching-rege
 (defun hi-lock-line-face-buffer (regexp &optional face)
   "Set face of all lines containing a match of REGEXP to FACE.
 Interactively, prompt for REGEXP then FACE.  Use
-`hi-lock-read-regexp-defaults-function' to retrieve default
+`hi-lock-read-regexp-defaults' to retrieve default
 value(s) of REGEXP.  Use the global history list for FACE.
 
 Use Font lock mode, if enabled, to highlight REGEXP.  Otherwise,
@@ -432,7 +412,7 @@ (defun hi-lock-line-face-buffer (regexp
    (list
     (hi-lock-regexp-okay
      (read-regexp "Regexp to highlight line"
-		  (funcall hi-lock-read-regexp-defaults-function)))
+		  (hi-lock-read-regexp-defaults)))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -448,7 +428,7 @@ (defalias 'highlight-regexp 'hi-lock-fac
 (defun hi-lock-face-buffer (regexp &optional face)
   "Set face of each match of REGEXP to FACE.
 Interactively, prompt for REGEXP then FACE.  Use
-`hi-lock-read-regexp-defaults-function' to retrieve default
+`hi-lock-read-regexp-defaults' to retrieve default
 value(s) REGEXP.  Use the global history list for FACE.
 
 Use Font lock mode, if enabled, to highlight REGEXP.  Otherwise,
@@ -458,7 +438,7 @@ (defun hi-lock-face-buffer (regexp &opti
    (list
     (hi-lock-regexp-okay
      (read-regexp "Regexp to highlight"
-		  (funcall hi-lock-read-regexp-defaults-function)))
+		  (hi-lock-read-regexp-defaults)))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -470,7 +450,7 @@ (defalias 'highlight-phrase 'hi-lock-fac
 (defun hi-lock-face-phrase-buffer (regexp &optional face)
   "Set face of each match of phrase REGEXP to FACE.
 Interactively, prompt for REGEXP then FACE.  Use
-`hi-lock-read-regexp-defaults-function' to retrieve default
+`hi-lock-read-regexp' to retrieve default
 value(s) of REGEXP.  Use the global history list for FACE.  When
 called interactively, replace whitespace in user provided regexp
 with arbitrary whitespace and make initial lower-case letters
@@ -484,7 +464,7 @@ (defun hi-lock-face-phrase-buffer (regex
     (hi-lock-regexp-okay
      (hi-lock-process-phrase
       (read-regexp "Phrase to highlight"
-		   (funcall hi-lock-read-regexp-defaults-function))))
+		   (hi-lock-read-regexp-defaults))))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -651,9 +631,22 @@ (defun hi-lock-regexp-okay (regexp)
     regexp))
 
 (defun hi-lock-read-regexp-defaults ()
-  "Return the latest regexp from `regexp-history'.
-See `hi-lock-read-regexp-defaults-function' for details."
-  (car regexp-history))
+  "Function that provides default regexp(s) for highlighting commands.
+This function takes no arguments and returns one of nil, a
+regexp or a list of regexps for use with highlighting commands -
+`hi-lock-face-phrase-buffer', `hi-lock-line-face-buffer' and
+`hi-lock-face-buffer'.  The return value of this function is used
+as DEFAULTS param of `read-regexp' while executing the
+highlighting command.  This function is called only during
+interactive use.
+
+You can customize `read-regexp-defaults-function' to the value
+`find-tag-default-as-regexp' to highlight a symbol at point.
+
+If you need different defaults for different highlighting
+operations, redefine this function and use `this-command'
+to identify the command under execution."
+  (read-regexp-defaults-history))
 
 (defun hi-lock-read-face-name ()
   "Return face for interactive highlighting.

=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el	2013-02-12 07:57:04 +0000
+++ lisp/progmodes/grep.el	2013-05-14 23:50:07 +0000
@@ -829,9 +829,13 @@ (defun grep-expand-template (template &o
 		     "")
 		 t t command))))))
 
+(defun grep-read-regexp-defaults ()
+  (or (read-regexp-defaults)
+      (grep-tag-default)))
+
 (defun grep-read-regexp ()
   "Read regexp arg for interactive grep."
-  (let ((default (grep-tag-default)))
+  (let ((default (grep-read-regexp-defaults)))
     (read-regexp
      (concat "Search for"
 	     (if (and default (> (length default) 0))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Wed, 15 May 2013 23:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Thu, 16 May 2013 01:58:33 +0300
> There are pending enhancements to create a single option to define
> the same defaulting behavior for all regexp-reading commands
> and to group the existing defaults to separate functions
> that can be overridden by customizing that option.

But note that the option `read-regexp-defaults-function' has
limited usefulness.  For example, in case when someone wants
`M-x man' to provide the default value not an entry near point
but the last element from the history, there is no way to do
this by customizing a common option because `man' uses the
specific variable `Man-topic-history'.

I see the only way to customize this by using `advice' like:

  (advice-add 'Man-default-man-entry :override
              (lambda () (car Man-topic-history)))

or even two default values (the last history and the original):

  (advice-add 'Man-default-man-entry :filter-return
              (lambda (r) (delq nil (list (car Man-topic-history) r))))

If advices are the preferable method of customization then the
design goal would be to add more functions returning default values
that users can customize using advices.  For example, for `grep'
there is already `grep-tag-default' that could be customized like:

  (advice-add 'grep-tag-default :override
              (lambda () (car grep-regexp-history)))

as a better advice for
http://stackoverflow.com/questions/15161592/make-emacs-rgrep-default-to-last-search-term-rather-than-word-at-point

Other commands require adding more functions for advice-based customization
like `occur-read-regexp-defaults' and `hi-lock-read-regexp-defaults'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Sat, 18 May 2013 23:34:02 GMT) Full text and rfc822 format available.

Message #11 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Sun, 19 May 2013 02:28:14 +0300
> +(defcustom read-regexp-defaults-function nil
> +  :type '(choice
> +          (const :tag "No default regexp reading function" nil)
> +          (choice :tag "Function to provide default for read-regexp"
> +		  (function-item :tag "Tag at point" find-tag-default)
> +		  (function-item :tag "Symbol at point" find-tag-default-as-regexp)
> +		  (function-item :tag "Latest history" (lambda () (car regexp-history)))

Actually there are two problems in this defcustom:

1. `find-tag-default' doesn't return a regexp.  To fix this problem,
we need two functions returning a regexp: as a non-symbol regexp and
as a symbol regexp.  I propose the following implementations:

  (defun find-tag-default-as-regexp ()
    "Return regexp that matches the default tag at point."
    (let ((tag (funcall (or find-tag-default-function
                            (get major-mode 'find-tag-default-function)
                            'find-tag-default))))
      (if tag (regexp-quote tag))))

  (defun find-tag-default-as-symbol-regexp ()
    "Return regexp that matches the default tag at point as symbol."
    (let ((tag-regexp (find-tag-default-as-regexp)))
      (if (and tag-regexp
               (eq (or find-tag-default-function
                       (get major-mode 'find-tag-default-function)
                       'find-tag-default)
                   'find-tag-default))
          (format "\\_<%s\\_>" tag-regexp)
        tag-regexp)))

2. The second problem is that `(lambda () (car regexp-history))'
can't be used in defcustom because many commands use history other than
`regexp-history'.

As a possible solution we could add a new special symbol
`default-last-history' to handle it in `read-regexp' that
has access to the actual value of the history variable in its arg
`history' using `(symbol-value (or history 'regexp-history))' below:

=== modified file 'lisp/replace.el'
--- lisp/replace.el	2013-03-24 21:47:52 +0000
+++ lisp/replace.el	2013-05-18 23:27:38 +0000
@@ -580,6 +580,24 @@ (defvar regexp-history nil
 (defvar occur-collect-regexp-history '("\\1")
   "History of regexp for occur's collect operation")
 
+(defcustom read-regexp-defaults-function nil
+  "Function that provides default regexp(s) for regexp reading commands."
+  :type '(choice
+	  (const :tag "No default regexp reading function" nil)
+	  (const :tag "Latest history" default-last-history)
+	  (function-item :tag "Tag at point" find-tag-default-as-regexp)
+	  (function-item :tag "Symbol at point" find-tag-default-as-symbol-regexp)
+	  (function :tag "Function to provide default for read-regexp"))
+  :group 'matching
+  :version "24.4")
+
 (defun read-regexp (prompt &optional defaults history)
   "Read and return a regular expression as a string.
 When PROMPT doesn't end with a colon and space, it adds a final \": \".
@@ -591,13 +609,23 @@ (defun read-regexp (prompt &optional def
 
 Optional arg HISTORY is a symbol to use for the history list.
 If HISTORY is nil, `regexp-history' is used."
-  (let* ((default     (if (consp defaults) (car defaults) defaults))
+  (let* ((defaults
+	   (if (and defaults (symbolp defaults))
+	       (cond
+		((eq (or read-regexp-defaults-function defaults)
+		     'default-last-history)
+		 (car (symbol-value (or history 'regexp-history))))
+		((functionp (or read-regexp-defaults-function defaults))
+		 (funcall (or read-regexp-defaults-function defaults))))
+	     defaults))
+	 (default     (if (consp defaults) (car defaults) defaults))
 	 (suggestions (if (listp defaults) defaults (list defaults)))
 	 (suggestions
 	  (append
 	   suggestions
 	   (list
 	    (find-tag-default-as-regexp)
+	    (find-tag-default-as-symbol-regexp)
 	    (car regexp-search-ring)
 	    (regexp-quote (or (car search-ring) ""))
 	    (car (symbol-value query-replace-from-history-variable)))))
@@ -1143,9 +1170,9 @@
 (defun occur-read-primary-args ()
   (let* ((perform-collect (consp current-prefix-arg))
          (regexp (read-regexp (if perform-collect
                                   "Collect strings matching regexp"
                                 "List lines matching regexp")
-                              (funcall occur-read-regexp-defaults-function))))
+                              'default-last-history)))
     (list regexp
 	  (if perform-collect
 	      ;; Perform collect operation

=== modified file 'lisp/hi-lock.el'
--- lisp/hi-lock.el	2013-03-31 13:34:35 +0000
+++ lisp/hi-lock.el	2013-05-18 23:27:23 +0000
@@ -431,8 +411,7 @@ (defun hi-lock-line-face-buffer (regexp
   (interactive
    (list
     (hi-lock-regexp-okay
-     (read-regexp "Regexp to highlight line"
-		  (funcall hi-lock-read-regexp-defaults-function)))
+     (read-regexp "Regexp to highlight line" 'default-last-history))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -457,8 +436,7 @@ (defun hi-lock-face-buffer (regexp &opti
   (interactive
    (list
     (hi-lock-regexp-okay
-     (read-regexp "Regexp to highlight"
-		  (funcall hi-lock-read-regexp-defaults-function)))
+     (read-regexp "Regexp to highlight" 'default-last-history))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))
@@ -483,8 +481,7 @@ (defun hi-lock-face-phrase-buffer (regex
    (list
     (hi-lock-regexp-okay
      (hi-lock-process-phrase
-      (read-regexp "Phrase to highlight"
-		   (funcall hi-lock-read-regexp-defaults-function))))
+      (read-regexp "Phrase to highlight" 'default-last-history)))
     (hi-lock-read-face-name)))
   (or (facep face) (setq face 'hi-yellow))
   (unless hi-lock-mode (hi-lock-mode 1))

=== modified file 'lisp/progmodes/grep.el'
--- lisp/progmodes/grep.el	2013-02-12 04:46:18 +0000
+++ lisp/progmodes/grep.el	2013-05-18 23:23:30 +0000
@@ -817,12 +831,7 @@ (defun grep-expand-template (template &o
 
 (defun grep-read-regexp ()
   "Read regexp arg for interactive grep."
-  (let ((default (grep-tag-default)))
-    (read-regexp
-     (concat "Search for"
-	     (if (and default (> (length default) 0))
-		 (format " (default \"%s\"): " default) ": "))
-     default 'grep-regexp-history)))
+  (read-regexp "Search for" 'grep-tag-default 'grep-regexp-history))
 
 (defun grep-read-files (regexp)
   "Read files arg for interactive grep."





bug closed, send any further explanations to 14405 <at> debbugs.gnu.org and Juri Linkov <juri <at> jurta.org> Request was from Juri Linkov <juri <at> jurta.org> to control <at> debbugs.gnu.org. (Fri, 20 Dec 2013 19:58:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Sat, 21 Dec 2013 07:21:02 GMT) Full text and rfc822 format available.

Message #16 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Jambunathan K <kjambunathan <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Sat, 21 Dec 2013 08:09:45 +0530
[Message part 1 (text/plain, inline)]
My workflow is M-s o searches for symbol at point.  Your recent commit
revno: 115651 closed this behaviour for me.  Just wanted to check
whether you overlooked the following diff.

The following works for me.

    (custom-set-variables
     '(read-regexp-defaults-function
       (quote find-tag-default-as-symbol-regexp)))

[Message part 2 (text/x-diff, inline)]
=== modified file 'lisp/replace.el'
--- lisp/replace.el	2013-12-20 19:55:56 +0000
+++ lisp/replace.el	2013-12-21 02:17:41 +0000
@@ -1239,7 +1239,7 @@ which means to discard all text properti
          (regexp (read-regexp (if perform-collect
                                   "Collect strings matching regexp"
                                 "List lines matching regexp")
-                              'regexp-history-last)))
+                              read-regexp-defaults-function)))
     (list regexp
 	  (if perform-collect
 	      ;; Perform collect operation


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Sat, 21 Dec 2013 21:36:02 GMT) Full text and rfc822 format available.

Message #19 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Jambunathan K <kjambunathan <at> gmail.com>
Cc: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Sat, 21 Dec 2013 23:25:41 +0200
> My workflow is M-s o searches for symbol at point.  Your recent commit
> revno: 115651 closed this behaviour for me.  Just wanted to check
> whether you overlooked the following diff.

For historical reasons, `M-s o' provides the previous history element as
the default.  I had no intention to change this default (because I recall
there were objections to changing the default behavior).  So if you want
`M-s o' to provide a symbol at point, you can customize
`read-regexp-defaults-function' to `find-tag-default-as-symbol-regexp'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Sat, 21 Dec 2013 23:02:01 GMT) Full text and rfc822 format available.

Message #22 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Jambunathan K <kjambunathan <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Sun, 22 Dec 2013 03:58:40 +0530
Juri Linkov <juri <at> jurta.org> writes:

>> My workflow is M-s o searches for symbol at point.  Your recent commit
>> revno: 115651 closed this behaviour for me.  Just wanted to check
>> whether you overlooked the following diff.
>
> For historical reasons, `M-s o' provides the previous history element as
> the default.  I had no intention to change this default (because I recall
> there were objections to changing the default behavior).  So if you want
> `M-s o' to provide a symbol at point, you can customize
> `read-regexp-defaults-function' to `find-tag-default-as-symbol-regexp'.

The diff attached with my mail indicates what the problem is.  Please
take a second look.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Sun, 22 Dec 2013 21:50:02 GMT) Full text and rfc822 format available.

Message #25 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Jambunathan K <kjambunathan <at> gmail.com>
Cc: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Sun, 22 Dec 2013 23:39:10 +0200
> The diff attached with my mail indicates what the problem is.  Please
> take a second look.

Maybe I'm missing something, maybe you're missing something,
but note that `read-regexp' already takes care about handling
`read-regexp-defaults-function' whose non-nil value
can override the default value in `occur-read-primary-args',
so no more additional changes are needed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Mon, 23 Dec 2013 18:28:03 GMT) Full text and rfc822 format available.

Message #28 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Jambunathan K <kjambunathan <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Mon, 23 Dec 2013 08:08:22 +0530
Juri Linkov <juri <at> jurta.org> writes:

> so no more additional changes are needed

True.  Sorry, my error.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Tue, 24 Dec 2013 18:54:03 GMT) Full text and rfc822 format available.

Message #31 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Jambunathan K <kjambunathan <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Tue, 24 Dec 2013 23:55:26 +0530
I depend on occur and rgrep.  For occur, I want the symbol delimiters.
For rgrep, a mere tag at point will do.  If one were to use multi-occur
from Buffer menu mode, a symbol match doesn't make sense.

Just a note.  I can fix .el files locally.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Wed, 25 Dec 2013 21:00:03 GMT) Full text and rfc822 format available.

Message #34 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Jambunathan K <kjambunathan <at> gmail.com>
Cc: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Wed, 25 Dec 2013 22:56:30 +0200
> I depend on occur and rgrep.  For occur, I want the symbol delimiters.
> For rgrep, a mere tag at point will do.  If one were to use multi-occur
> from Buffer menu mode, a symbol match doesn't make sense.

You can use `this-command' for different defaults of different commands
in a customized function like you wrote in the docstring that is
still preserved in `read-regexp-defaults-function'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14405; Package emacs. (Fri, 27 Dec 2013 19:29:01 GMT) Full text and rfc822 format available.

Message #37 received at 14405 <at> debbugs.gnu.org (full text, mbox):

From: Jambunathan K <kjambunathan <at> gmail.com>
To: Juri Linkov <juri <at> jurta.org>
Cc: 14405 <at> debbugs.gnu.org
Subject: Re: bug#14405: 24.3.50; read-regexp-defaults-function
Date: Fri, 27 Dec 2013 10:52:31 +0530
Juri Linkov <juri <at> jurta.org> writes:

>> I depend on occur and rgrep.  For occur, I want the symbol delimiters.
>> For rgrep, a mere tag at point will do.  If one were to use multi-occur
>> from Buffer menu mode, a symbol match doesn't make sense.
>
> You can use `this-command' for different defaults of different commands
> in a customized function like you wrote in the docstring that is
> still preserved in `read-regexp-defaults-function'.

For the benefit of googler out there.

    (setq read-regexp-defaults-function
          (lambda nil
            (pcase this-command
              (`rgrep (find-tag-default-as-regexp))
              (_ (find-tag-default-as-symbol-regexp)))))

It would be a good idea to choose a different name for
find-tag-default-*?  The function retrieves the tag-at-point but doesn't
find it (as in M-.).  So "find" is misleading.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 25 Jan 2014 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 102 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.