unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#31094: 25.2: Feature Reuqest: apropos-value: limit scope [CODE INCLUDED]
@ 2018-04-08  7:39 Boruch Baum
  2018-04-08 11:09 ` bug#31094: Code for second solution Boruch Baum
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Boruch Baum @ 2018-04-08  7:39 UTC (permalink / raw)
  To: 31094

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

I've begun using function apropos-value, and find that its ouput is
undesirably huge, because the feature prints out the entire value of
each variable that contains a match.

Some of this can be reduced when considegring that in most cases, I know
in advance that a value will be present in some very commonly used huge
variables, that won't be of use to me (eg. kill-ring,
minibuffer-history).f

A better solution would be an option to initially print only the names
of symbol that contain a match. The user can then easily view any value
of interest, because the output buffer already includes a feature that
pressing return on any symbol in the output list will display the
documentation for the symbol, which will include the variable's value.

Attached was my first thought at a solution, using an exclude list to
exclude certain variables from a search. As I said, upon further
consideration, I decided it would be better to abbreviate the output
buffer to just a list of symbol names, but I came to that conclusion
after writing the snippet.

-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

[-- Attachment #2: apropos-value.el --]
[-- Type: text/plain, Size: 2547 bytes --]

(defcustom apropos-value-exclude-list
  '(kill-ring values minibuffer-history buffer-name-history
     command-history ivy--all-candidates)
"List of variable names to be excluded from `apropos-value' searches."
  :type '(repeat variable))


(defun my-apropos-value (pattern &optional do-all)
  "Allow `apropos-value' to limit scope of its searches.

With \\[universal-argument] prefix, or if `apropos-do-all' is
non-nil, also looks at function definitions (arguments,
documentation and body) and at the names and values of
properties.

With two \\[universal-argument] prefixes, excludes the variables
listed in `apropos-value-exclude-list' from its search.

With three \\[universal-argument] prefixes, performs a search
only on the variables listed in `apropos-value-exclude-list'.

See also variable `apropos-value-limited-print'."
  (interactive (list (apropos-read-pattern "value")
		     current-prefix-arg))
  (apropos-parse-pattern pattern)
  (or do-all (when apropos-do-all (setq do-all '(4))))
  (setq apropos-accumulator ())
  (let (f v p)
    (if (equal do-all '(64)) ; C-u C-u C-u
      (dolist (symbol apropos-value-exclude-list)
        (when (setq v (apropos-value-internal 'boundp symbol 'symbol-value))
          (setq apropos-accumulator
            (cons (list symbol (apropos-score-str v) nil v nil) apropos-accumulator))))
     (mapatoms (lambda (symbol)
       (setq f nil v nil p nil)
       (or (memq symbol '(apropos-regexp
       		   apropos-pattern apropos-all-words-regexp
       		   apropos-words apropos-all-words
       		   do-all apropos-accumulator apropos-value-exclude-list
       		   symbol f v p))
           (and (equal do-all '(16)) ; C-u C-u
                (memq symbol apropos-value-exclude-list))
           (setq v (apropos-value-internal 'boundp symbol 'symbol-value)))
       (when (equal do-all '(4)) ; C-u
         (setq f (apropos-value-internal 'fboundp symbol 'symbol-function)
               p (apropos-format-plist symbol "\n    " t)))
       (if (apropos-false-hit-str v)
           (setq v nil))
       (if (apropos-false-hit-str f)
           (setq f nil))
       (if (apropos-false-hit-str p)
           (setq p nil))
       (if (or f v p)
           (setq apropos-accumulator (cons (list symbol
       					  (+ (apropos-score-str f)
       					     (apropos-score-str v)
       					     (apropos-score-str p))
       					  f v p)
       				    apropos-accumulator)))))))
  (let ((apropos-multi-type (if (equal do-all '(4)) t nil)))
    (apropos-print nil "\n----------------\n")))

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

end of thread, other threads:[~2022-01-25 12:03 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-08  7:39 bug#31094: 25.2: Feature Reuqest: apropos-value: limit scope [CODE INCLUDED] Boruch Baum
2018-04-08 11:09 ` bug#31094: Code for second solution Boruch Baum
2018-04-08 13:06   ` Eli Zaretskii
2018-04-08 13:17     ` Boruch Baum
2018-04-08 13:54       ` Eli Zaretskii
2018-04-08 14:13         ` Boruch Baum
2018-04-08 16:32           ` Eli Zaretskii
2022-01-23 14:45 ` bug#31094: 25.2: Feature Reuqest: apropos-value: limit scope [CODE INCLUDED] Lars Ingebrigtsen
2022-01-23 18:02   ` Juri Linkov
2022-01-23 18:29     ` Lars Ingebrigtsen
2022-01-23 20:02       ` Juri Linkov
2022-01-24  9:26         ` Lars Ingebrigtsen
2022-01-24 17:58           ` Juri Linkov
2022-01-24 18:33             ` Lars Ingebrigtsen
2022-01-24 19:19               ` Juri Linkov
2022-01-25 12:03                 ` Lars Ingebrigtsen
2022-01-25  2:06 ` Michael Heerdegen

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