summaryrefslogtreecommitdiff
path: root/lisp/man.el
diff options
context:
space:
mode:
authorJuanma Barranquero <lekktu@gmail.com>2003-07-13 17:16:31 +0000
committerJuanma Barranquero <lekktu@gmail.com>2003-07-13 17:16:31 +0000
commit7e734986ab48dfda91450d672d5f701959d17569 (patch)
treecc59bb3988292b511fa27e090dbc02b7fd8bd4da /lisp/man.el
parent76b7c637127de4ac50fbbd8c840ea9778a7f3249 (diff)
downloademacs-7e734986ab48dfda91450d672d5f701959d17569.tar.gz
(Man-translate-cleanup): New.
(Man-translate-references): Call `Man-translate-cleanup' to clean leading, trailing and middle spaces.
Diffstat (limited to 'lisp/man.el')
-rw-r--r--lisp/man.el20
1 files changed, 17 insertions, 3 deletions
diff --git a/lisp/man.el b/lisp/man.el
index f46d731c745..a2ff8ad3d53 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -504,17 +504,30 @@ This is necessary if one wants to dump man.el with Emacs."
(error "Malformed Man-filter-list"))
phrase)
pargs " ")))
- (setq flist (cdr flist))))
+ (setq flist (cdr flist))))
command))
+
+(defun Man-translate-cleanup (string)
+ "Strip leading, trailing and middle spaces."
+ (when (stringp string)
+ ;; Strip leading and trailing
+ (if (string-match "^[ \t\f\r\n]*\\(.+[^ \t\f\r\n]\\)" string)
+ (setq string (match-string 1 string)))
+ ;; middle spaces
+ (setq string (replace-regexp-in-string "[\t\r\n]" " " string))
+ (setq string (replace-regexp-in-string " +" " " string))
+ string))
+
(defun Man-translate-references (ref)
"Translates REF from \"chmod(2V)\" to \"2v chmod\" style.
Leave it as is if already in that style. Possibly downcase and
translate the section (see the Man-downcase-section-letters-flag
and the Man-section-translations-alist variables)."
(let ((name "")
- (section "")
- (slist Man-section-translations-alist))
+ (section "")
+ (slist Man-section-translations-alist))
+ (setq ref (Man-translate-cleanup ref))
(cond
;; "chmod(2V)" case ?
((string-match (concat "^" Man-reference-regexp "$") ref)
@@ -578,6 +591,7 @@ This guess is based on the text surrounding the cursor."
;;;###autoload
(defalias 'manual-entry 'man)
+
;;;###autoload
(defun man (man-args)
"Get a Un*x manual page and put it in a buffer.