emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/help-fns.el [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/help-fns.el [lexbind]
Date: Tue, 06 Jul 2004 07:15:25 -0400

Index: emacs/lisp/help-fns.el
diff -c emacs/lisp/help-fns.el:1.9.2.9 emacs/lisp/help-fns.el:1.9.2.10
*** emacs/lisp/help-fns.el:1.9.2.9      Tue May 11 02:29:01 2004
--- emacs/lisp/help-fns.el      Tue Jul  6 09:14:18 2004
***************
*** 158,188 ****
          ;; Return the text we displayed.
          (buffer-string))))))
  
! (defun help-split-fundoc (doc def)
!   "Split a function docstring DOC into the actual doc and the usage info.
  Return (USAGE . DOC) or nil if there's no usage info.
! DEF is the function whose usage we're looking for in DOC."
    ;; Functions can get the calling sequence at the end of the doc string.
    ;; In cases where `function' has been fset to a subr we can't search for
    ;; function's name in the doc string so we use `fn' as the anonymous
    ;; function name instead.
!   (when (and doc (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc))
      (cons (format "(%s%s"
                  ;; Replace `fn' with the actual function name.
                  (if (consp def) "anonymous" def)
!                 (match-string 1 doc))
!         (substring doc 0 (match-beginning 0)))))
  
! (defun help-add-fundoc-usage (doc arglist)
!   "Add the usage info to the docstring DOC.
! If DOC already has a usage info, then just return DOC unchanged.
! The usage info is built from ARGLIST.  DOC can be nil.
! ARGLIST can also be t or a string of the form \"(fun ARG1 ARG2 ...)\"."
!   (unless (stringp doc) (setq doc "Not documented"))
!   (if (or (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" doc) (eq arglist t))
!       doc
!     (format "%s%s%S" doc
!           (if (string-match "\n?\n\\'" doc)
                (if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "")
              "\n\n")
            (if (and (stringp arglist)
--- 158,188 ----
          ;; Return the text we displayed.
          (buffer-string))))))
  
! (defun help-split-fundoc (docstring def)
!   "Split a function DOCSTRING into the actual doc and the usage info.
  Return (USAGE . DOC) or nil if there's no usage info.
! DEF is the function whose usage we're looking for in DOCSTRING."
    ;; Functions can get the calling sequence at the end of the doc string.
    ;; In cases where `function' has been fset to a subr we can't search for
    ;; function's name in the doc string so we use `fn' as the anonymous
    ;; function name instead.
!   (when (and docstring (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" docstring))
      (cons (format "(%s%s"
                  ;; Replace `fn' with the actual function name.
                  (if (consp def) "anonymous" def)
!                 (match-string 1 docstring))
!         (substring docstring 0 (match-beginning 0)))))
  
! (defun help-add-fundoc-usage (docstring arglist)
!   "Add the usage info to DOCSTRING.
! If DOCSTRING already has a usage info, then just return it unchanged.
! The usage info is built from ARGLIST.  DOCSTRING can be nil.
! ARGLIST can also be t or a string of the form \"(FUN ARG1 ARG2 ...)\"."
!   (unless (stringp docstring) (setq docstring "Not documented"))
!   (if (or (string-match "\n\n(fn\\(\\( .*\\)?)\\)\\'" docstring) (eq arglist 
t))
!       docstring
!     (format "%s%s%S" docstring
!           (if (string-match "\n?\n\\'" docstring)
                (if (< (- (match-end 0) (match-beginning 0)) 2) "\n" "")
              "\n\n")
            (if (and (stringp arglist)
***************
*** 239,246 ****
            (concat "src/" file)
          file)))))
  
! (defface help-argument-name '((t (:slant italic)))
!   "Face to highlight function arguments in docstrings.")
  
  (defun help-do-arg-highlight (doc args)
    (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table)
--- 239,252 ----
            (concat "src/" file)
          file)))))
  
! (defun help-default-arg-highlight (arg)
!   "Default function to highlight arguments in *Help* buffers.
! It returns ARG in lowercase italics, if the display supports it;
! else ARG is returned in uppercase normal."
!   (let ((attrs '(:slant italic)))
!     (if (display-supports-face-attributes-p attrs)
!         (propertize (downcase arg) 'face attrs)
!       arg)))
  
  (defun help-do-arg-highlight (doc args)
    (with-syntax-table (make-syntax-table emacs-lisp-mode-syntax-table)
***************
*** 248,255 ****
      (while args
        (let ((arg (prog1 (car args) (setq args (cdr args)))))
          (setq doc (replace-regexp-in-string
!                    (concat "\\<\\(" arg "\\)\\(?:es\\|s\\|th\\)?\\>")
!                    (propertize arg 'face 'help-argument-name)
                     doc t t 1))))
      doc))
  
--- 254,270 ----
      (while args
        (let ((arg (prog1 (car args) (setq args (cdr args)))))
          (setq doc (replace-regexp-in-string
!                    ;; This is heuristic, but covers all common cases
!                    ;; except ARG1-ARG2
!                    (concat "\\<"                   ; beginning of word
!                            "\\(?:[a-z-]+-\\)?"     ; for xxx-ARG
!                            "\\("
!                            arg
!                            "\\)"
!                            "\\(?:es\\|s\\|th\\)?"  ; for ARGth, ARGs
!                            "\\(?:-[a-z-]+\\)?"     ; for ARG-xxx
!                            "\\>")                  ; end of word
!                    (help-default-arg-highlight arg)
                     doc t t 1))))
      doc))
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]