/[emacs]/emacs/lisp/help-fns.el
ViewVC logotype

Diff of /emacs/lisp/help-fns.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by pj, Sat Dec 22 13:35:14 2001 UTC revision 1.5 by rms, Mon Jan 7 05:20:33 2002 UTC
# Line 127  and the file name is displayed in the ec Line 127  and the file name is displayed in the ec
127    (if (null function)    (if (null function)
128        (message "You didn't specify a function")        (message "You didn't specify a function")
129      (help-setup-xref (list #'describe-function function) (interactive-p))      (help-setup-xref (list #'describe-function function) (interactive-p))
130      (with-output-to-temp-buffer (help-buffer)      (save-excursion
131        (prin1 function)        (with-output-to-temp-buffer (help-buffer)
132        ;; Use " is " instead of a colon so that          (prin1 function)
133        ;; it is easier to get out the function name using forward-sexp.          ;; Use " is " instead of a colon so that
134        (princ " is ")          ;; it is easier to get out the function name using forward-sexp.
135        (describe-function-1 function)          (princ " is ")
136        (print-help-return-message)          (describe-function-1 function)
137        (with-current-buffer standard-output          (print-help-return-message)
138          ;; Return the text we displayed.          (with-current-buffer standard-output
139          (buffer-string)))))            ;; Return the text we displayed.
140              (buffer-string))))))
141    
142  ;;;###autoload  ;;;###autoload
143  (defun describe-function-1 (function)  (defun describe-function-1 (function)
# Line 193  and the file name is displayed in the ec Line 194  and the file name is displayed in the ec
194          (setq file-name (symbol-file function)))          (setq file-name (symbol-file function)))
195      (cond      (cond
196       (file-name       (file-name
197            (princ " in `")        (princ " in `")
198            ;; We used to add .el to the file name,        ;; We used to add .el to the file name,
199            ;; but that's completely wrong when the user used load-file.        ;; but that's completely wrong when the user used load-file.
200            (princ file-name)        (princ file-name)
201            (princ "'")        (princ "'")
202            ;; Make a hyperlink to the library.        ;; Make a hyperlink to the library.
203        (with-current-buffer standard-output        (with-current-buffer standard-output
204              (save-excursion          (save-excursion
205                (re-search-backward "`\\([^`']+\\)'" nil t)            (re-search-backward "`\\([^`']+\\)'" nil t)
206            (help-xref-button 1 'help-function-def function file-name)))))            (help-xref-button 1 'help-function-def function file-name)))))
207      (princ ".")      (princ ".")
208      (terpri)      (terpri)
# Line 315  it is displayed along with the global va Line 316  it is displayed along with the global va
316    (unless (bufferp buffer) (setq buffer (current-buffer)))    (unless (bufferp buffer) (setq buffer (current-buffer)))
317    (if (not (symbolp variable))    (if (not (symbolp variable))
318        (message "You did not specify a variable")        (message "You did not specify a variable")
319      (let (valvoid)      (save-excursion
320        (help-setup-xref (list #'describe-variable variable buffer)        (let (valvoid)
321                         (interactive-p))          (help-setup-xref (list #'describe-variable variable buffer)
322        (with-output-to-temp-buffer (help-buffer)                           (interactive-p))
323        (with-current-buffer buffer          (with-output-to-temp-buffer (help-buffer)
324            (prin1 variable)            (with-current-buffer buffer
325            (if (not (boundp variable))              (prin1 variable)
326                (progn              (if (not (boundp variable))
327                  (princ " is void")                  (progn
328                  (setq valvoid t))                    (princ " is void")
329              (let ((val (symbol-value variable)))                    (setq valvoid t))
330                (with-current-buffer standard-output                (let ((val (symbol-value variable)))
                 (princ "'s value is ")  
                 (terpri)  
                 (let ((from (point)))  
                   (pp val)  
                   (help-xref-on-pp from (point))  
                   (if (< (point) (+ from 20))  
                       (save-excursion  
                         (goto-char from)  
                         (delete-char -1)))))))  
           (terpri)  
           (when (local-variable-p variable)  
             (princ (format "Local in buffer %s; " (buffer-name)))  
             (if (not (default-boundp variable))  
                 (princ "globally void")  
               (let ((val (default-value variable)))  
331                  (with-current-buffer standard-output                  (with-current-buffer standard-output
332                    (princ "global value is ")                    (princ "'s value is ")
333                    (terpri)                    (terpri)
                   ;; Fixme: pp can take an age if you happen to  
                   ;; ask for a very large expression.  We should  
                   ;; probably print it raw once and check it's a  
                   ;; sensible size before prettyprinting.  -- fx  
334                    (let ((from (point)))                    (let ((from (point)))
335                          (pp val)                      (pp val)
336                          (help-xref-on-pp from (point))                      (help-xref-on-pp from (point))
337                          (if (< (point) (+ from 20))                      (if (< (point) (+ from 20))
338                              (save-excursion                          (save-excursion
339                                (goto-char from)                            (goto-char from)
340                                (delete-char -1)))))))                            (delete-char -1)))))))
341              (terpri))              (terpri)
342            (terpri)              (when (local-variable-p variable)
343            (with-current-buffer standard-output                (princ (format "Local in buffer %s; " (buffer-name)))
344              (when (> (count-lines (point-min) (point-max)) 10)                (if (not (default-boundp variable))
345                ;; Note that setting the syntax table like below                    (princ "globally void")
346                ;; makes forward-sexp move over a `'s' at the end                  (let ((val (default-value variable)))
347                ;; of a symbol.                    (with-current-buffer standard-output
348                (set-syntax-table emacs-lisp-mode-syntax-table)                      (princ "global value is ")
349                (goto-char (point-min))                      (terpri)
350                (if valvoid                      ;; Fixme: pp can take an age if you happen to
351                    (forward-line 1)                      ;; ask for a very large expression.  We should
352                  (forward-sexp 1)                      ;; probably print it raw once and check it's a
353                  (delete-region (point) (progn (end-of-line) (point)))                      ;; sensible size before prettyprinting.  -- fx
354                  (insert " value is shown below.\n\n")                      (let ((from (point)))
355                          (pp val)
356                          (help-xref-on-pp from (point))
357                          (if (< (point) (+ from 20))
358                              (save-excursion
359                                (goto-char from)
360                                (delete-char -1)))))))
361                  (terpri))
362                (terpri)
363                (with-current-buffer standard-output
364                  (when (> (count-lines (point-min) (point-max)) 10)
365                    ;; Note that setting the syntax table like below
366                    ;; makes forward-sexp move over a `'s' at the end
367                    ;; of a symbol.
368                    (set-syntax-table emacs-lisp-mode-syntax-table)
369                    (goto-char (point-min))
370                    (if valvoid
371                        (forward-line 1)
372                      (forward-sexp 1)
373                      (delete-region (point) (progn (end-of-line) (point)))
374                      (insert " value is shown below.\n\n")
375                      (save-excursion
376                        (insert "\n\nValue:"))))
377                  ;; Add a note for variables that have been make-var-buffer-local.
378                  (when (and (local-variable-if-set-p variable)
379                             (or (not (local-variable-p variable))
380                                 (with-temp-buffer
381                                   (local-variable-if-set-p variable))))
382                  (save-excursion                  (save-excursion
383                    (insert "\n\nValue:"))))                    (forward-line -1)
384              ;; Add a note for variables that have been make-var-buffer-local.                    (insert "Automatically becomes buffer-local when set in any fashion.\n"))))
385              (when (and (local-variable-if-set-p variable)              (princ "Documentation:")
386                         (or (not (local-variable-p variable))              (terpri)
387                             (with-temp-buffer              (let ((doc (documentation-property variable 'variable-documentation)))
388                               (local-variable-if-set-p variable))))                (princ (or doc "not documented as a variable.")))
               (save-excursion  
                 (forward-line -1)  
                 (insert "Automatically becomes buffer-local when set in any fashion.\n"))))  
           (princ "Documentation:")  
           (terpri)  
           (let ((doc (documentation-property variable 'variable-documentation)))  
             (princ (or doc "not documented as a variable.")))  
389                        
390            ;; Make a link to customize if this variable can be customized.              ;; Make a link to customize if this variable can be customized.
391            ;; Note, it is not reliable to test only for a custom-type property              ;; Note, it is not reliable to test only for a custom-type property
392            ;; because those are only present after the var's definition              ;; because those are only present after the var's definition
393            ;; has been loaded.              ;; has been loaded.
394            (if (or (get variable 'custom-type) ; after defcustom              (if (or (get variable 'custom-type) ; after defcustom
395                    (get variable 'custom-loads) ; from loaddefs.el                      (get variable 'custom-loads) ; from loaddefs.el
396                    (get variable 'standard-value)) ; from cus-start.el                      (get variable 'standard-value)) ; from cus-start.el
397                (let ((customize-label "customize"))                  (let ((customize-label "customize"))
398                  (terpri)                    (terpri)
399                  (terpri)                    (terpri)
400                  (princ (concat "You can " customize-label " this variable."))                    (princ (concat "You can " customize-label " this variable."))
401                      (with-current-buffer standard-output
402                        (save-excursion
403                          (re-search-backward
404                           (concat "\\(" customize-label "\\)") nil t)
405                          (help-xref-button 1 'help-customize-variable variable)))))
406                ;; Make a hyperlink to the library if appropriate.  (Don't
407                ;; change the format of the buffer's initial line in case
408                ;; anything expects the current format.)
409                (let ((file-name (symbol-file variable)))
410                  (when (equal file-name "loaddefs.el")
411                    ;; Find the real def site of the preloaded variable.
412                    (let ((location
413                           (condition-case nil
414                               (find-variable-noselect variable file-name)
415                             (error nil))))
416                      (when location
417                        (with-current-buffer (car location)
418                          (goto-char (cdr location))
419                          (when (re-search-backward
420                                 "^;;; Generated autoloads from \\(.*\\)" nil t)
421                            (setq file-name (match-string 1)))))))
422                  (when file-name
423                    (princ "\n\nDefined in `")
424                    (princ file-name)
425                    (princ "'.")
426                  (with-current-buffer standard-output                  (with-current-buffer standard-output
427                    (save-excursion                    (save-excursion
428                      (re-search-backward                      (re-search-backward "`\\([^`']+\\)'" nil t)
429                       (concat "\\(" customize-label "\\)") nil t)                      (help-xref-button 1 'help-variable-def
430                      (help-xref-button 1 'help-customize-variable variable)))))                                        variable file-name)))))
           ;; Make a hyperlink to the library if appropriate.  (Don't  
           ;; change the format of the buffer's initial line in case  
           ;; anything expects the current format.)  
           (let ((file-name (symbol-file variable)))  
             (when (equal file-name "loaddefs.el")  
               ;; Find the real def site of the preloaded variable.  
               (let ((location  
                      (condition-case nil  
                          (find-variable-noselect variable file-name)  
                        (error nil))))  
                 (when location  
                   (with-current-buffer (car location)  
                     (goto-char (cdr location))  
                     (when (re-search-backward  
                            "^;;; Generated autoloads from \\(.*\\)" nil t)  
                       (setq file-name (match-string 1)))))))  
             (when file-name  
               (princ "\n\nDefined in `")  
               (princ file-name)  
               (princ "'.")  
               (with-current-buffer standard-output  
                 (save-excursion  
                   (re-search-backward "`\\([^`']+\\)'" nil t)  
                   (help-xref-button 1 'help-variable-def  
                                     variable file-name)))))  
431    
432            (print-help-return-message)              (print-help-return-message)
433            (save-excursion              (save-excursion
434              (set-buffer standard-output)                (set-buffer standard-output)
435              ;; Return the text we displayed.                ;; Return the text we displayed.
436              (buffer-string)))))))                (buffer-string))))))))
437    
438    
439  ;;;###autoload  ;;;###autoload

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26