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

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