aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2003-07-13 17:16:31 +0000
committerJuanma Barranquero2003-07-13 17:16:31 +0000
commit7e734986ab48dfda91450d672d5f701959d17569 (patch)
treecc59bb3988292b511fa27e090dbc02b7fd8bd4da
parent76b7c637127de4ac50fbbd8c840ea9778a7f3249 (diff)
downloademacs-7e734986ab48dfda91450d672d5f701959d17569.tar.gz
emacs-7e734986ab48dfda91450d672d5f701959d17569.zip
(Man-translate-cleanup): New.
(Man-translate-references): Call `Man-translate-cleanup' to clean leading, trailing and middle spaces.
-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."
504 (error "Malformed Man-filter-list")) 504 (error "Malformed Man-filter-list"))
505 phrase) 505 phrase)
506 pargs " "))) 506 pargs " ")))
507 (setq flist (cdr flist)))) 507 (setq flist (cdr flist))))
508 command)) 508 command))
509 509
510
511(defun Man-translate-cleanup (string)
512 "Strip leading, trailing and middle spaces."
513 (when (stringp string)
514 ;; Strip leading and trailing
515 (if (string-match "^[ \t\f\r\n]*\\(.+[^ \t\f\r\n]\\)" string)
516 (setq string (match-string 1 string)))
517 ;; middle spaces
518 (setq string (replace-regexp-in-string "[\t\r\n]" " " string))
519 (setq string (replace-regexp-in-string " +" " " string))
520 string))
521
510(defun Man-translate-references (ref) 522(defun Man-translate-references (ref)
511 "Translates REF from \"chmod(2V)\" to \"2v chmod\" style. 523 "Translates REF from \"chmod(2V)\" to \"2v chmod\" style.
512Leave it as is if already in that style. Possibly downcase and 524Leave it as is if already in that style. Possibly downcase and
513translate the section (see the Man-downcase-section-letters-flag 525translate the section (see the Man-downcase-section-letters-flag
514and the Man-section-translations-alist variables)." 526and the Man-section-translations-alist variables)."
515 (let ((name "") 527 (let ((name "")
516 (section "") 528 (section "")
517 (slist Man-section-translations-alist)) 529 (slist Man-section-translations-alist))
530 (setq ref (Man-translate-cleanup ref))
518 (cond 531 (cond
519 ;; "chmod(2V)" case ? 532 ;; "chmod(2V)" case ?
520 ((string-match (concat "^" Man-reference-regexp "$") ref) 533 ((string-match (concat "^" Man-reference-regexp "$") ref)
@@ -578,6 +591,7 @@ This guess is based on the text surrounding the cursor."
578;;;###autoload 591;;;###autoload
579(defalias 'manual-entry 'man) 592(defalias 'manual-entry 'man)
580 593
594
581;;;###autoload 595;;;###autoload
582(defun man (man-args) 596(defun man (man-args)
583 "Get a Un*x manual page and put it in a buffer. 597 "Get a Un*x manual page and put it in a buffer.