From: Drew Adams <drew.adams@oracle.com>
To: Eli Zaretskii <eliz@gnu.org>, Drew Adams <drew.adams@oracle.com>
Cc: 31807@debbugs.gnu.org
Subject: bug#31807: 27.0; `info-apropos' bad name or bad matching
Date: Thu, 14 Jun 2018 13:45:38 -0700 (PDT) [thread overview]
Message-ID: <cd94ca9a-5d36-44a2-8162-57f1a3dc639e@default> (raw)
In-Reply-To: <<83in6l30ir.fsf@gnu.org>>
> > If you want to keep the current behavior then I'd suggest
> > having two different commands AND, for the one that does
> > literal string matching, change the name to something that
> > does not include "apropos" in the name.
>
> I'm okay with a new command, but it should have a new name. How about
> info-apropos-regexp? The old command must keep its name, for the same
> reason we cannot change its behavior.
>
> > When I get some time I'll take a closer look.
>
> Thanks.
Here's the code I've included in my library `info+.el'.
You may want to use it in `info.el'. Or not.
If you want to rename `info-apropos' here to `info-apropos-regexp', do so.
And you might want other changes, too. It should be pretty clear what
the essential changes are, versus others that you might not want to make.
(I untabify, I use `add-to-list' for backward compatibility, and I use
a separate window if invoked outside Info.)
HTH.
;; REPLACE ORIGINAL in `info.el':
;;
;; Added optional arg LITERALP. Use apropos matching, not literal-string matching,
;; by default. Prefix arg matches literally.
;; Use other window, unless already in Info.
;;
(defun info-apropos (pattern &optional literalp)
"Search indexes of all known Info files on your system for apropos PATTERN.
Build a menu of the possible matches.
With a prefix arg, match PATTERN as a literal string, not as a regexp
or keywords.
Just as for commands such as `apropos', PATTERN can be a word, a list
of words (separated by spaces), or a regexp (using some regexp special
characters). If it is a word, search for matches for that word as a
substring. If it is a list of words, search for matches for any
two (or more) of those words."
(interactive (list (apropos-read-pattern "index entries") current-prefix-arg))
(apropos-parse-pattern pattern)
(if (equal apropos-regexp "")
(Info-find-node Info-apropos-file "Top")
(let ((nodes Info-apropos-nodes)
nodename)
(while (and nodes (not (string-match apropos-regexp (nth 1 (car nodes)))))
(setq nodes (cdr nodes)))
;; Use another window, if not already in Info.
(unless (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
(if nodes
(Info-find-node Info-apropos-file (caar nodes))
(setq nodename (format "Index for '%s'" apropos-regexp))
(push (list nodename
apropos-regexp
(Info-apropos-matches apropos-regexp (and (not literalp) 'REGEXP)))
Info-apropos-nodes)
(Info-find-node Info-apropos-file nodename)))))
;; REPLACE ORIGINAL in `info.el':
;;
;; Added optional arg REGEXP-P.
;;
(defun Info-apropos-matches (string &optional regexp-p)
"Collect STRING matches from all known Info files on your system.
Return a list of matches where each element is in the format
\((FILENAME INDEXTEXT NODENAME LINENUMBER)).
Non-nil optional REGEXP-P means interpret STRING as a regexp, instead
of trying to match it literally."
;; Emacs 23 has an `interactive' spec here, for no reason.
(unless (string= string "")
(let ((pattern (format "\n\\* +\\([^\n]*\\(%s\\)[^\n]*\\):[ \t]+\
\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
(if regexp-p string (regexp-quote string))))
(ohist Info-history)
(ohist-list Info-history-list)
(current-node Info-current-node)
(current-file Info-current-file)
manuals matches node nodes)
(let ((Info-fontify-maximum-menu-size nil))
(Info-directory)
;; `current-node' and `current-file' are nil if you invoke `info-apropos' as
;; the first Info command. (`info-apropos' loads `info.el'.) In that case,
;; use `(DIR)Top', to avoid an error after search is complete.
(unless current-node (setq current-file Info-current-file
current-node Info-current-node))
(message "Searching indices...")
(goto-char (point-min))
(re-search-forward "\\* Menu: *\n" nil t)
;; Ensure no duplicates in MANUALS, so the `dolist' runs faster.
(while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t)
(add-to-list 'manuals (match-string 1)))
(dolist (manual (nreverse manuals))
(message "Searching %s" manual)
(condition-case err
(if (setq nodes (Info-index-nodes (Info-find-file manual)))
(save-excursion
(Info-find-node manual (car nodes))
(while
(progn
(goto-char (point-min))
(while (re-search-forward pattern nil t)
(let ((entry (match-string-no-properties 1))
(nodename (match-string-no-properties 3))
(line (match-string-no-properties 4)))
(add-text-properties
(- (match-beginning 2) (match-beginning 1))
(- (match-end 2) (match-beginning 1))
'(face info-index-match) entry)
(setq matches (cons (list manual entry nodename line)
matches))))
(setq nodes (cdr nodes)
node (car nodes)))
(Info-goto-node node))))
(error (message "%s" (if (eq (car-safe err) 'error) (nth 1 err) err))
(sit-for 1 t)))))
(Info-find-node current-file current-node)
(setq Info-history ohist
Info-history-list ohist-list)
(message "Searching indices...done")
(or (nreverse matches) t))))
next prev parent reply other threads:[~2018-06-14 20:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <<78156de2-86c8-4593-92b5-59edf7a8996e@default>
[not found] ` <<83o9gd33dj.fsf@gnu.org>
[not found] ` <<a4bf1dd4-d411-4a74-b5dd-9b7abaef9250@default>
[not found] ` <<83in6l30ir.fsf@gnu.org>
2018-06-14 14:42 ` bug#31807: 27.0; `info-apropos' bad name or bad matching Drew Adams
2018-06-14 15:09 ` Eli Zaretskii
2018-06-14 20:45 ` Drew Adams [this message]
2022-04-21 15:05 ` Lars Ingebrigtsen
2022-04-21 20:04 ` Drew Adams
[not found] <<<<78156de2-86c8-4593-92b5-59edf7a8996e@default>
[not found] ` <<<<83o9gd33dj.fsf@gnu.org>
[not found] ` <<<<a4bf1dd4-d411-4a74-b5dd-9b7abaef9250@default>
[not found] ` <<<<83in6l30ir.fsf@gnu.org>
[not found] ` <<<5fc07c84-b8d2-493c-a17b-774ad1c213bf@default>
[not found] ` <<<83fu1p2ym7.fsf@gnu.org>
[not found] ` <<73c2c21d-9fba-4ab5-a0b0-8b36e9a23bcf@default>
[not found] ` <<83efh92wr2.fsf@gnu.org>
2018-06-14 15:58 ` Drew Adams
[not found] <<<78156de2-86c8-4593-92b5-59edf7a8996e@default>
[not found] ` <<<83o9gd33dj.fsf@gnu.org>
[not found] ` <<<a4bf1dd4-d411-4a74-b5dd-9b7abaef9250@default>
[not found] ` <<<83in6l30ir.fsf@gnu.org>
[not found] ` <<5fc07c84-b8d2-493c-a17b-774ad1c213bf@default>
[not found] ` <<83fu1p2ym7.fsf@gnu.org>
2018-06-14 15:33 ` Drew Adams
2018-06-14 15:50 ` Eli Zaretskii
2018-06-12 23:01 Drew Adams
2018-06-12 23:21 ` Drew Adams
2018-06-12 23:39 ` Drew Adams
2018-06-12 23:59 ` Drew Adams
2018-06-14 13:29 ` Eli Zaretskii
2018-06-13 0:04 ` Noam Postavsky
2018-06-13 0:16 ` Drew Adams
2018-06-13 18:24 ` Drew Adams
[not found] ` <<eb245b09-a156-4585-8021-7a3e0e173dbc@default>
[not found] ` <<83muvx33ab.fsf@gnu.org>
2018-06-14 14:16 ` Drew Adams
2018-06-17 7:44 ` Eli Zaretskii
[not found] ` <<<eb245b09-a156-4585-8021-7a3e0e173dbc@default>
[not found] ` <<<83muvx33ab.fsf@gnu.org>
[not found] ` <<f7814f7b-d9c0-48d5-83aa-b354b047db10@default>
[not found] ` <<83muvtuab9.fsf@gnu.org>
2018-06-17 14:26 ` Drew Adams
2018-06-14 13:27 ` Eli Zaretskii
2018-06-14 14:11 ` Drew Adams
2018-06-14 14:28 ` Eli Zaretskii
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=cd94ca9a-5d36-44a2-8162-57f1a3dc639e@default \
--to=drew.adams@oracle.com \
--cc=31807@debbugs.gnu.org \
--cc=eliz@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).