unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* feature proposal: occur-read-primary-args: (from Xemacs)
@ 2015-12-27 16:42 Uwe Brauer
  2015-12-31  0:22 ` Juri Linkov
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Brauer @ 2015-12-27 16:42 UTC (permalink / raw)
  To: emacs-devel

hello


Coming form Xemacs, there is one feature I miss. In Xemacs when I use
occur, the minibuffers offer me the word (symbol) the cursor is on.
Now looking at the code, I found out that there is *no* difference in
the definition of occur.

(defun occur (regexp &optional nlines)
  (interactive (occur-read-primary-args))
  (occur-1 regexp nlines (list (current-buffer))))

But in the function (occur-read-primary-args)

Which is defined for Xemacs as follows:

(defun occur-read-primary-args ()
  (list (let* ((default (or (symbol-near-point)
			    (and regexp-history
				 (car regexp-history))))
	       (minibuffer-history-minimum-string-length 0)
	       (input
		 (if default
		     ;; XEmacs: rewritten for I18N3 snarfing
		     (read-from-minibuffer
		      (format "List lines matching regexp (default `%s'): "
			      default) nil nil nil 'regexp-history nil
                              default)
		   (read-from-minibuffer
		    "List lines matching regexp: "
		    nil nil nil
		    'regexp-history))))
	  (if (equal input "")
	      default
	    input))
	(when current-prefix-arg
	  (prefix-numeric-value current-prefix-arg))))

The essential point seems to be the let* which defines default, which
needs the function symbol-near-point

which in turn is given:
(defun symbol-near-point ()
  "Return the first textual item to the nearest point."
  (interactive)
  ;alg stolen from etag.el
  (save-excursion
	(if (or (bobp) (not (memq (char-syntax (char-before)) '(?w ?_))))
	    (while (not (looking-at "\\sw\\|\\s_\\|\\'"))
	      (forward-char 1)))
	(while (looking-at "\\sw\\|\\s_")
	  (forward-char 1))
	(if (re-search-backward "\\sw\\|\\s_" nil t)
	    (regexp-quote
	     (progn (forward-char 1)
		    (buffer-substring (point)
				      (progn (forward-sexp -1)
					     (while (looking-at "\\s'")
					       (forward-char 1))
					     (point)))))
	  nil)))


So the question boils down to this, could this feature be implemented in
GNU emacs, either by directly using symbol-near-point or a different
implementation?

Thanks

Uwe Brauer 




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

* Re: feature proposal: occur-read-primary-args: (from Xemacs)
  2015-12-27 16:42 feature proposal: occur-read-primary-args: (from Xemacs) Uwe Brauer
@ 2015-12-31  0:22 ` Juri Linkov
  2015-12-31  3:34   ` Eli Zaretskii
  2015-12-31 16:48   ` Uwe Brauer
  0 siblings, 2 replies; 6+ messages in thread
From: Juri Linkov @ 2015-12-31  0:22 UTC (permalink / raw)
  To: emacs-devel

> So the question boils down to this, could this feature be implemented in
> GNU emacs, either by directly using symbol-near-point or a different
> implementation?

This feature is already implemented in GNU Emacs where you can customize
‘read-regexp-defaults-function’.



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

* Re: feature proposal: occur-read-primary-args: (from Xemacs)
  2015-12-31  0:22 ` Juri Linkov
@ 2015-12-31  3:34   ` Eli Zaretskii
  2015-12-31 16:49     ` Uwe Brauer
  2015-12-31 16:48   ` Uwe Brauer
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2015-12-31  3:34 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

> From: Juri Linkov <juri@linkov.net>
> Date: Thu, 31 Dec 2015 02:22:16 +0200
> 
> > So the question boils down to this, could this feature be implemented in
> > GNU emacs, either by directly using symbol-near-point or a different
> > implementation?
> 
> This feature is already implemented in GNU Emacs where you can customize
> ‘read-regexp-defaults-function’.

I actually wonder whether Uwe knows about a much simpler to use
feature: type M-n or <down> arrow at the Occur prompt.



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

* Re: feature proposal: occur-read-primary-args: (from Xemacs)
  2015-12-31  0:22 ` Juri Linkov
  2015-12-31  3:34   ` Eli Zaretskii
@ 2015-12-31 16:48   ` Uwe Brauer
  1 sibling, 0 replies; 6+ messages in thread
From: Uwe Brauer @ 2015-12-31 16:48 UTC (permalink / raw)
  To: emacs-devel

>>> "Juri" == Juri Linkov <juri@linkov.net> writes:

    >> So the question boils down to this, could this feature be
    >> implemented in GNU emacs, either by directly using
    >> symbol-near-point or a different implementation?

    > This feature is already implemented in GNU Emacs where you can
    > customize ‘read-regexp-defaults-function’.

Thanks, this was precisely what I was looking for, the recommended
setting to find-tag-default-as-regexp did the job. Why to making this
the default?





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

* Re: feature proposal: occur-read-primary-args: (from Xemacs)
  2015-12-31  3:34   ` Eli Zaretskii
@ 2015-12-31 16:49     ` Uwe Brauer
  2015-12-31 18:50       ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Brauer @ 2015-12-31 16:49 UTC (permalink / raw)
  To: emacs-devel



   > I actually wonder whether Uwe knows about a much simpler to use
   > feature: type M-n or <down> arrow at the Occur prompt.


No I did not, but your solution is hitting one key more :-D




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

* RE: feature proposal: occur-read-primary-args: (from Xemacs)
  2015-12-31 16:49     ` Uwe Brauer
@ 2015-12-31 18:50       ` Drew Adams
  0 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2015-12-31 18:50 UTC (permalink / raw)
  To: Uwe Brauer, emacs-devel

>    > I actually wonder whether Uwe knows about a much simpler to use
>    > feature: type M-n or <down> arrow at the Occur prompt.
> 
> No I did not, but your solution is hitting one key more :-D

That's because Emacs does not insert the default value into the
minibuffer as an "initial value".  For one thing, since Emacs 23
there can be multiple default values, which you can retrieve, one
by one, using `M-n' repeatedly.

---

[If you use Icicles then you can opt to have Emacs automatically
insert the (first) default value in the minibuffer, so you do
not need to use `M-n' to retrieve it.  (In that case, if you do
not want it you can hit `M-k' to remove it.)

You choose the behavior you want by customizing option
`icicle-default-value'.  You can choose to insert the default
value or not; and if inserted, whether to leave the cursor
before or after it, and whether to preselect it.]



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

end of thread, other threads:[~2015-12-31 18:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-27 16:42 feature proposal: occur-read-primary-args: (from Xemacs) Uwe Brauer
2015-12-31  0:22 ` Juri Linkov
2015-12-31  3:34   ` Eli Zaretskii
2015-12-31 16:49     ` Uwe Brauer
2015-12-31 18:50       ` Drew Adams
2015-12-31 16:48   ` Uwe Brauer

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).