unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-devel@gnu.org
Subject: feature proposal: occur-read-primary-args: (from Xemacs)
Date: Sun, 27 Dec 2015 16:42:19 +0000	[thread overview]
Message-ID: <87lh8fkfmc.fsf@mat.ucm.es> (raw)

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 




             reply	other threads:[~2015-12-27 16:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-27 16:42 Uwe Brauer [this message]
2015-12-31  0:22 ` feature proposal: occur-read-primary-args: (from Xemacs) 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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87lh8fkfmc.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-devel@gnu.org \
    /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 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).