emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature proposal: occur-read-primary-args: (from Xemacs)


From: Uwe Brauer
Subject: feature proposal: occur-read-primary-args: (from Xemacs)
Date: Sun, 27 Dec 2015 16:42:19 +0000
User-agent: Gnus/5.13001 (Ma Gnus v0.10) Emacs/25.0.50 (gnu/linux)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]