comparison lisp/man.el @ 51892:3146f91c8c99

(Man-translate-cleanup): New. (Man-translate-references): Call `Man-translate-cleanup' to clean leading, trailing and middle spaces.
author Juanma Barranquero <lekktu@gmail.com>
date Sun, 13 Jul 2003 17:16:31 +0000
parents ebe64300a9d5
children c97fe9557de4
comparison
equal deleted inserted replaced
51891:62a53410dbd8 51892:3146f91c8c99
502 (mapconcat (lambda (phrase) 502 (mapconcat (lambda (phrase)
503 (if (not (stringp phrase)) 503 (if (not (stringp phrase))
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
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))
509 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.
512 Leave it as is if already in that style. Possibly downcase and 524 Leave it as is if already in that style. Possibly downcase and
513 translate the section (see the Man-downcase-section-letters-flag 525 translate the section (see the Man-downcase-section-letters-flag
514 and the Man-section-translations-alist variables)." 526 and 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)
521 (setq name (match-string 1 ref) 534 (setq name (match-string 1 ref)
522 section (match-string 2 ref))) 535 section (match-string 2 ref)))
575 ;; Top level command and background process sentinel 588 ;; Top level command and background process sentinel
576 589
577 ;; For compatibility with older versions. 590 ;; For compatibility with older versions.
578 ;;;###autoload 591 ;;;###autoload
579 (defalias 'manual-entry 'man) 592 (defalias 'manual-entry 'man)
593
580 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.
584 This command is the top-level command in the man package. It runs a Un*x 598 This command is the top-level command in the man package. It runs a Un*x