/[emacs]/emacs/lisp/woman.el
ViewVC logotype

Diff of /emacs/lisp/woman.el

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

revision 1.37 by eliz, Fri Sep 9 12:29:02 2005 UTC revision 1.38 by eliz, Sat Sep 10 14:57:32 2005 UTC
# Line 136  Line 136 
136  ;;   man man_page_name  ;;   man man_page_name
137    
138    
139  ;; Using the `word at point' as a topic suggestion  ;; Using the word at point as the default topic
140  ;; ===============================================  ;; ============================================
141    
142  ;; By default, the `woman' command uses the word nearest to point in  ;; The `woman' command uses the word nearest to point in the current
143  ;; the current buffer as a suggestion for the topic to look up.  The  ;; buffer as the default topic to look up if it matches the name of a
144  ;; topic must be confirmed or edited in the minibuffer.  This  ;; manual page installed on the system.  The default topic can also be
145  ;; suggestion can be turned off, or `woman' can use the suggested  ;; used without confirmation by setting the user-option
146  ;; topic without confirmation* if possible, by setting the user-option  ;; `woman-use-topic-at-point' to t; thanks to Benjamin Riefenstahl for
147  ;; `woman-topic-at-point' to nil or t respectively.  (Its default  ;; suggesting this functionality.
 ;; value is neither nil nor t, meaning ask for confirmation.)  
148    
149  ;; [* Thanks to Benjamin Riefenstahl for suggesting this  ;; The variable `woman-use-topic-at-point' can be rebound locally,
150  ;; functionality.]  ;; which may be useful to provide special private key bindings, e.g.
   
 ;; The variable `woman-topic-at-point' can be rebound locally, which  
 ;; may be useful to provide special private key bindings, e.g.  
151    
152  ;;  (global-set-key "\C-cw"  ;;  (global-set-key "\C-cw"
153  ;;                (lambda ()  ;;                (lambda ()
154  ;;                  (interactive)  ;;                  (interactive)
155  ;;                  (let ((woman-topic-at-point t))  ;;                  (let ((woman-use-topic-at-point t))
156  ;;                    (woman)))))  ;;                    (woman)))))
157    
158    
# Line 711  Default is \"CONTENTS\"." Line 707  Default is \"CONTENTS\"."
707    :type 'string    :type 'string
708    :group 'woman-interface)    :group 'woman-interface)
709    
710  (defcustom woman-topic-at-point-default 'confirm  (defcustom woman-use-topic-at-point-default nil
711    ;; `woman-topic-at-point' may be let-bound when woman is loaded, in    ;; `woman-use-topic-at-point' may be let-bound when woman is loaded,
712    ;; which case its global value does not get defined.    ;; in which case its global value does not get defined.
713    ;; `woman-file-name' sets it to this value if it is unbound.    ;; `woman-file-name' sets it to this value if it is unbound.
714    "*Default value for `woman-topic-at-point'."    "*Default value for `woman-use-topic-at-point'."
715    :type '(choice (const :tag "Yes" t)    :type '(choice (const :tag "Yes" t)
716                   (const :tag "No" nil)                   (const :tag "No" nil))
                  (other :tag "Confirm" confirm))  
717    :group 'woman-interface)    :group 'woman-interface)
718    
719  (defcustom woman-topic-at-point woman-topic-at-point-default  (defcustom woman-use-topic-at-point woman-use-topic-at-point-default
720    "*Controls use by `woman' of `word at point' as a topic suggestion.    "*Control use of the word at point as the default topic.
721  If non-nil then the `woman' command uses the word at point as an  If non-nil the `woman' command uses the word at point automatically,
722  initial topic suggestion when it reads a topic from the minibuffer; if  without interactive confirmation, if it exists as a topic."
 t then the `woman' command uses the word at point WITHOUT  
 INTERACTIVE CONFIRMATION if it exists as a topic.  The default value  
 is `confirm', meaning suggest a topic and ask for confirmation."  
723    :type '(choice (const :tag "Yes" t)    :type '(choice (const :tag "Yes" t)
724                   (const :tag "No" nil)                   (const :tag "No" nil))
                  (other :tag "Confirm" confirm))  
725    :group 'woman-interface)    :group 'woman-interface)
726    
727  (defvar woman-file-regexp nil  (defvar woman-file-regexp nil
# Line 1198  It is saved to the file named by the var Line 1189  It is saved to the file named by the var
1189    
1190  (defun woman-file-name (topic &optional re-cache)  (defun woman-file-name (topic &optional re-cache)
1191    "Get the name of the UN*X man-page file describing a chosen TOPIC.    "Get the name of the UN*X man-page file describing a chosen TOPIC.
1192  When `woman' is called interactively, the word at point may be used as  When `woman' is called interactively, the word at point may be
1193  the topic or initial topic suggestion, subject to the value of the  automatically used as the topic, if the value of the user option
1194  user option `woman-topic-at-point'.  Return nil if no file can be found.  `woman-use-topic-at-point' is non-nil.  Return nil if no file can
1195  Optional argument RE-CACHE, if non-nil, forces the cache to be re-read."  be found.  Optional argument RE-CACHE, if non-nil, forces the
1196    cache to be re-read."
1197    ;; Handle the caching of the directory and topic lists:    ;; Handle the caching of the directory and topic lists:
1198    (if (and (not re-cache)    (if (and (not re-cache)
1199             (or             (or
# Line 1222  Optional argument RE-CACHE, if non-nil, Line 1214  Optional argument RE-CACHE, if non-nil,
1214    (let (files    (let (files
1215          (default (current-word)))          (default (current-word)))
1216      (or (stringp topic)      (or (stringp topic)
1217          (and (eq t          (and (if (boundp 'woman-use-topic-at-point)
1218                   (if (boundp 'woman-topic-at-point)                   woman-use-topic-at-point
1219                       woman-topic-at-point                 ;; Was let-bound when file loaded, so ...
1220                     ;; Was let-bound when file loaded, so ...                 (setq woman-use-topic-at-point woman-use-topic-at-point-default))
1221                     (setq woman-topic-at-point woman-topic-at-point-default)))               (setq topic (or (current-word t) "")) ; only within or adjacent to word
1222               (setq topic               (test-completion topic woman-topic-all-completions))
                    (or (current-word t) ""))    ; only within or adjacent to word  
              (assoc topic woman-topic-all-completions))  
1223          (setq topic          (setq topic
1224                (completing-read                (let* ((word-at-point (current-word))
1225                 (if default                       (default
1226                     (format "Manual entry (default `%s'): " default)                         (when (and word-at-point
1227                   "Manual entry: ")                                    (test-completion
1228                 woman-topic-all-completions nil 1                                     word-at-point woman-topic-all-completions))
1229                 nil                           word-at-point)))
1230                 'woman-topic-history                  (completing-read
1231                 ;; Default topic.                   (if default
1232                 (and woman-topic-at-point                       (format "Manual entry [default: %s]: " default)
1233                      default))))                     "Manual entry: ")
1234                     woman-topic-all-completions nil 1
1235                     nil
1236                     'woman-topic-history
1237                     default))))
1238      ;; Note that completing-read always returns a string.      ;; Note that completing-read always returns a string.
1239      (if (= (length topic) 0)      (if (= (length topic) 0)
1240          nil                             ; no topic, so no file!          nil                             ; no topic, so no file!

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

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