unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Boruch Baum <boruch_baum@gmx.com>
To: 31094@debbugs.gnu.org
Subject: bug#31094: 25.2: Feature Reuqest: apropos-value: limit scope [CODE INCLUDED]
Date: Sun, 8 Apr 2018 03:39:16 -0400	[thread overview]
Message-ID: <20180408073916.d5lsceul3gpj34l3@E15-2016.optimum.net> (raw)

[-- 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")))

             reply	other threads:[~2018-04-08  7:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-08  7:39 Boruch Baum [this message]
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

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=20180408073916.d5lsceul3gpj34l3@E15-2016.optimum.net \
    --to=boruch_baum@gmx.com \
    --cc=31094@debbugs.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).