From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emilio Lopes Newsgroups: gmane.emacs.devel Subject: patch for woman (woman-topic-at-point) Date: Thu, 25 Aug 2005 20:48:30 +0200 Organization: private Message-ID: <38wtm926pt.fsf@tiscali.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1124997566 23368 80.91.229.2 (25 Aug 2005 19:19:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 25 Aug 2005 19:19:26 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 25 21:19:25 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1E8NFK-0005qx-2b for ged-emacs-devel@m.gmane.org; Thu, 25 Aug 2005 21:18:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E8NJD-0004AD-84 for ged-emacs-devel@m.gmane.org; Thu, 25 Aug 2005 15:22:43 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1E8NIs-00048k-8a for emacs-devel@gnu.org; Thu, 25 Aug 2005 15:22:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1E8NIq-00047u-6u for emacs-devel@gnu.org; Thu, 25 Aug 2005 15:22:20 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1E8N9o-0001Im-Bo for emacs-devel@gnu.org; Thu, 25 Aug 2005 15:13:00 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1E8Msa-0001I7-FH for emacs-devel@gnu.org; Thu, 25 Aug 2005 14:55:12 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1E8MpC-0005U4-P4 for emacs-devel@gnu.org; Thu, 25 Aug 2005 20:51:42 +0200 Original-Received: from p62.246.18.165.tisdip.tiscali.de ([62.246.18.165]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Aug 2005 20:51:42 +0200 Original-Received: from eclig by p62.246.18.165.tisdip.tiscali.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Aug 2005 20:51:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 215 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: p62.246.18.165.tisdip.tiscali.de User-Agent: Emacs Gnus Cancel-Lock: sha1:Hr9lhEOYMAjHv1wo9JIVdq+OGoM= X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:42409 Archived-At: [ Sorry for the long message. I wanted to make the problem clear also for people not familiar with `woman'. ] The variable `woman-topic-at-point' controls whether the command `woman' should offer the word at point as a suggestion when asking the user for the name of a manual page. The default value is `confirm' and being neither t nor nil means to use the word at point as a suggestion but give the user the option to reject or confirm this suggestion. The problem is that "to suggest" for `woman' means to actually *insert* the suggested name in the minibuffer, a behavior described as deprecated in the documentation of `completing-read'. And because the word at point rarely (at least for me) is the name of a man page actually installed in the system, this means that most of the time the user has the burden of having to delete the useless suggestion before entering the desired man page. I find this annoying. The following patch introduces a new possible value for `woman-topic-at-point': if this variable is the symbol `exact', `woman' will offer the word at point as a default ONLY IF it actually matches the name of an existing man page in the system. Even in this case it will *not* insert the suggestion in the minibuffer. This change is backwards compatible. If I could only change the behavior of *any* woman with a patch :-) 2005-08-19 Emilio C. Lopes * woman.el (woman-topic-at-point-default, woman-topic-at-point): new possible value `exact'. (woman-file-name): support for this new value of `woman-topic-at-point'. diff -rN -c old-emacs-darcs.eclig/lisp/woman.el new-emacs-darcs.eclig/lisp/woman.el *** old-emacs-darcs.eclig/lisp/woman.el Thu Aug 25 19:59:24 2005 --- new-emacs-darcs.eclig/lisp/woman.el Fri Aug 19 18:07:36 2005 *************** *** 144,151 **** ;; topic must be confirmed or edited in the minibuffer. This ;; suggestion can be turned off, or `woman' can use the suggested ;; topic without confirmation* if possible, by setting the user-option ! ;; `woman-topic-at-point' to nil or t respectively. (Its default ! ;; value is neither nil nor t, meaning ask for confirmation.) ;; [* Thanks to Benjamin Riefenstahl for suggesting this ;; functionality.] --- 144,153 ---- ;; topic must be confirmed or edited in the minibuffer. This ;; suggestion can be turned off, or `woman' can use the suggested ;; topic without confirmation* if possible, by setting the user-option ! ;; `woman-topic-at-point' to nil or t respectively. If it is the ! ;; symbol `exact' then the word at point will be offered as a ! ;; suggestion only if it is an exact match for an existing topic. ! ;; (Its default value is none of these, meaning ask for confirmation.) ;; [* Thanks to Benjamin Riefenstahl for suggesting this ;; functionality.] *************** *** 422,430 **** ;; Geoff Voelker ;; Eli Zaretskii - ;;; History: - ;; For recent change log see end of file. - ;;; Code: --- 424,429 ---- *************** *** 721,738 **** "*Default value for `woman-topic-at-point'." :type '(choice (const :tag "Yes" t) (const :tag "No" nil) (other :tag "Confirm" confirm)) :group 'woman-interface) (defcustom woman-topic-at-point woman-topic-at-point-default "*Controls use by `woman' of `word at point' as a topic suggestion. ! If non-nil then the `woman' command uses the word at point as an ! initial topic suggestion when it reads a topic from the minibuffer; if ! 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." :type '(choice (const :tag "Yes" t) (const :tag "No" nil) (other :tag "Confirm" confirm)) :group 'woman-interface) --- 720,743 ---- "*Default value for `woman-topic-at-point'." :type '(choice (const :tag "Yes" t) (const :tag "No" nil) + (const :tag "Exact" exact) (other :tag "Confirm" confirm)) :group 'woman-interface) (defcustom woman-topic-at-point woman-topic-at-point-default "*Controls use by `woman' of `word at point' as a topic suggestion. ! If t then the `woman' command uses the word at point WITHOUT ! INTERACTIVE CONFIRMATION if it exists as a topic. ! If it is the symbol `exact' then the word at point will be offered ! as a suggestion only if it is an exact match for an existing topic. ! If it has other non-nil value then the `woman' command uses the word ! at point as an initial topic suggestion when it reads a topic from ! the minibuffer. ! The default value is `confirm', meaning suggest a topic and ask ! for confirmation." :type '(choice (const :tag "Yes" t) (const :tag "No" nil) + (const :tag "Exact" exact) (other :tag "Confirm" confirm)) :group 'woman-interface) *************** *** 956,963 **** :group 'woman-faces) (defcustom woman-use-symbol-font nil ! "*If non-nil then may use the symbol font. It is off by default, ! mainly because it may change the line spacing (in NTEmacs 20.5)." :type 'boolean :group 'woman-faces) --- 961,969 ---- :group 'woman-faces) (defcustom woman-use-symbol-font nil ! "*If non-nil then may use the symbol font. ! It is off by default,mainly because it may change the line spacing ! \(in NTEmacs 20.5)." :type 'boolean :group 'woman-faces) *************** *** 1229,1245 **** ;; Was let-bound when file loaded, so ... (setq woman-topic-at-point woman-topic-at-point-default))) (setq topic ! (or (current-word t) "")) ; only within or adjacent to word (assoc topic woman-topic-all-completions)) (setq topic ! (completing-read ! "Manual entry: " ! woman-topic-all-completions nil 1 ! ;; Initial input suggestion (was nil), with ! ;; cursor at left ready to kill suggestion!: ! (and woman-topic-at-point ! (cons (or (current-word) "") 0)) ; nearest word ! 'woman-topic-history))) ;; Note that completing-read always returns a string. (if (= (length topic) 0) nil ; no topic, so no file! --- 1235,1266 ---- ;; Was let-bound when file loaded, so ... (setq woman-topic-at-point woman-topic-at-point-default))) (setq topic ! (or (current-word t) "")) ; only within or adjacent to word (assoc topic woman-topic-all-completions)) (setq topic ! (let (initial default) ! (cond ! ((eq woman-topic-at-point 'exact) ! (setq initial nil) ! (setq default (and (current-word) ! (car (assoc (current-word) ! woman-topic-all-completions))))) ! (woman-topic-at-point ; any other non-nil value ! ;; Initial input suggestion, with cursor at left ! ;; ready to kill suggestion! ! (setq initial (cons (or (current-word) "") 0)) ! (setq default nil)) ! (t ! (setq initial nil) ! (setq default nil))) ! (completing-read ! (if default ! (format "Manual entry [default: %s]: " default) ! "Manual entry: ") ! woman-topic-all-completions nil 1 ! initial ! 'woman-topic-history ! default)))) ;; Note that completing-read always returns a string. (if (= (length topic) 0) nil ; no topic, so no file! *************** *** 1259,1268 **** ;; Unread the command event (TAB = ?\t = 9) that runs the command ;; `minibuffer-complete' in order to automatically complete the ;; minibuffer contents as far as possible. ! (setq unread-command-events '(9)) ; and delete any type-ahead! (completing-read "Manual file: " files nil 1 ! (try-completion "" files) 'woman-file-history))) ! ))) (defun woman-select (predicate list) "Select unique elements for which PREDICATE is true in LIST. --- 1280,1288 ---- ;; Unread the command event (TAB = ?\t = 9) that runs the command ;; `minibuffer-complete' in order to automatically complete the ;; minibuffer contents as far as possible. ! (setq unread-command-events '(9)) ; and delete any type-ahead! (completing-read "Manual file: " files nil 1 ! (try-completion "" files) 'woman-file-history)))))) (defun woman-select (predicate list) "Select unique elements for which PREDICATE is true in LIST.