summaryrefslogtreecommitdiff
path: root/lisp/man.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2012-04-28 17:59:08 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2012-04-28 17:59:08 -0400
commit8b6c19f4c23e69f2133a8432d614abdc03bdadc6 (patch)
tree50b1ab560ca298e2cf06898ee11b1ed1df1bb000 /lisp/man.el
parent461ef3c5186ce4df67039615b30b84b0c86d7da4 (diff)
downloademacs-8b6c19f4c23e69f2133a8432d614abdc03bdadc6.tar.gz
Avoid the obsolete `assoc' package.
* lisp/speedbar.el (speedbar-refresh): Avoid adelete. (speedbar-file-lists): Simplify and avoid aput. * lisp/man.el (Man--sections, Man--refpages): New vars, replacing Man-sections-alist and Man-refpages-alist. (Man-build-section-alist, Man-build-references-alist): Use them; avoid aput. (Man--last-section, Man--last-refpage): New vars. (Man-follow-manual-reference): Use them. Use the `default' arg of completing-read. (Man-goto-section): Idem. Move prompt to the `interactive' spec. * lisp/gnus/auth-source.el (auth-source--aput-1, auth-source--aput) (auth-source--aget): New functions and macros. Use them instead of aput/aget.
Diffstat (limited to 'lisp/man.el')
-rw-r--r--lisp/man.el91
1 files changed, 46 insertions, 45 deletions
diff --git a/lisp/man.el b/lisp/man.el
index 0a7b831ca8e..6912486dffa 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -89,7 +89,6 @@
;;; Code:
(eval-when-compile (require 'cl))
-(require 'assoc)
(require 'button)
;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
@@ -360,10 +359,10 @@ Otherwise, the value is whatever the function
(make-variable-buffer-local 'Man-arguments)
(put 'Man-arguments 'permanent-local t)
-(defvar Man-sections-alist nil)
-(make-variable-buffer-local 'Man-sections-alist)
-(defvar Man-refpages-alist nil)
-(make-variable-buffer-local 'Man-refpages-alist)
+(defvar Man--sections nil)
+(make-variable-buffer-local 'Man--sections)
+(defvar Man--refpages nil)
+(make-variable-buffer-local 'Man--refpages)
(defvar Man-page-list nil)
(make-variable-buffer-local 'Man-page-list)
(defvar Man-current-page 0)
@@ -1370,17 +1369,19 @@ The following key bindings are currently in effect in the buffer:
(run-mode-hooks 'Man-mode-hook))
(defsubst Man-build-section-alist ()
- "Build the association list of manpage sections."
- (setq Man-sections-alist nil)
+ "Build the list of manpage sections."
+ (setq Man--sections nil)
(goto-char (point-min))
(let ((case-fold-search nil))
(while (re-search-forward Man-heading-regexp (point-max) t)
- (aput 'Man-sections-alist (match-string 1))
+ (let ((section (match-string 1)))
+ (unless (member section Man--sections)
+ (push section Man--sections)))
(forward-line 1))))
(defsubst Man-build-references-alist ()
- "Build the association list of references (in the SEE ALSO section)."
- (setq Man-refpages-alist nil)
+ "Build the list of references (in the SEE ALSO section)."
+ (setq Man--refpages nil)
(save-excursion
(if (Man-find-section Man-see-also-regexp)
(let ((start (progn (forward-line 1) (point)))
@@ -1406,10 +1407,11 @@ The following key bindings are currently in effect in the buffer:
len (1- (length word))))
(if (memq (aref word len) '(?- ?­))
(setq hyphenated (substring word 0 len)))
- (if (string-match Man-reference-regexp word)
- (aput 'Man-refpages-alist word))))
+ (and (string-match Man-reference-regexp word)
+ (not (member word Man--refpages))
+ (push word Man--refpages))))
(skip-chars-forward " \t\n,"))))))
- (setq Man-refpages-alist (nreverse Man-refpages-alist)))
+ (setq Man--refpages (nreverse Man--refpages)))
(defun Man-build-page-list ()
"Build the list of separate manpages in the buffer."
@@ -1541,21 +1543,22 @@ Returns t if section is found, nil otherwise."
nil)
))
-(defun Man-goto-section ()
- "Query for section to move point to."
- (interactive)
- (aput 'Man-sections-alist
- (let* ((default (aheadsym Man-sections-alist))
- (completion-ignore-case t)
- chosen
- (prompt (concat "Go to section (default " default "): ")))
- (setq chosen (completing-read prompt Man-sections-alist))
- (if (or (not chosen)
- (string= chosen ""))
- default
- chosen)))
- (unless (Man-find-section (aheadsym Man-sections-alist))
- (error "Section not found")))
+(defvar Man--last-section nil)
+
+(defun Man-goto-section (section)
+ "Move point to SECTION."
+ (interactive
+ (let* ((default (if (member Man--last-section Man--sections)
+ Man--last-section
+ (car Man--sections)))
+ (completion-ignore-case t)
+ (prompt (concat "Go to section (default " default "): "))
+ (chosen (completing-read prompt Man--sections
+ nil nil nil nil default)))
+ (list chosen)))
+ (setq Man--last-section section)
+ (unless (Man-find-section section)
+ (error "Section %s not found" section)))
(defun Man-goto-see-also-section ()
@@ -1586,11 +1589,13 @@ as \"tcgetp-grp(3V)\", and point is at \"grp(3V)\", we return
(setq word (current-word))))
word)))
+(defvar Man--last-refpage nil)
+
(defun Man-follow-manual-reference (reference)
"Get one of the manpages referred to in the \"SEE ALSO\" section.
Specify which REFERENCE to use; default is based on word at point."
(interactive
- (if (not Man-refpages-alist)
+ (if (not Man--refpages)
(error "There are no references in the current man page")
(list
(let* ((default (or
@@ -1603,26 +1608,22 @@ Specify which REFERENCE to use; default is based on word at point."
(substring word 0
(match-beginning 0))
word))
- Man-refpages-alist))
- (aheadsym Man-refpages-alist)))
+ Man--refpages))
+ (if (member Man--last-refpage Man--refpages)
+ Man--last-refpage
+ (car Man--refpages))))
(defaults
(mapcar 'substring-no-properties
- (delete-dups
- (delq nil (cons default
- (mapcar 'car Man-refpages-alist))))))
- chosen
- (prompt (concat "Refer to (default " default "): ")))
- (setq chosen (completing-read prompt Man-refpages-alist
- nil nil nil nil defaults))
- (if (or (not chosen)
- (string= chosen ""))
- default
- chosen)))))
- (if (not Man-refpages-alist)
+ (cons default Man--refpages)))
+ (prompt (concat "Refer to (default " default "): "))
+ (chosen (completing-read prompt Man--refpages
+ nil nil nil nil defaults)))
+ chosen))))
+ (if (not Man--refpages)
(error "Can't find any references in the current manpage")
- (aput 'Man-refpages-alist reference)
+ (setq Man--last-refpage reference)
(Man-getpage-in-background
- (Man-translate-references (aheadsym Man-refpages-alist)))))
+ (Man-translate-references reference))))
(defun Man-kill ()
"Kill the buffer containing the manpage."