From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?R=FCdiger?= Sonderfeld Newsgroups: gmane.emacs.devel Subject: [PATCH 2/3] octave.el: Add `octave-apropos' function. Date: Fri, 27 Sep 2013 15:11:28 +0200 Message-ID: <2808254.TOFES3Zzvm@descartes> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1380287516 12685 80.91.229.3 (27 Sep 2013 13:11:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 27 Sep 2013 13:11:56 +0000 (UTC) Cc: Leo Liu To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 27 15:11:59 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VPXps-0001pb-K7 for ged-emacs-devel@m.gmane.org; Fri, 27 Sep 2013 15:11:56 +0200 Original-Received: from localhost ([::1]:36185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPXpr-0005hF-Vv for ged-emacs-devel@m.gmane.org; Fri, 27 Sep 2013 09:11:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPXpa-0005Pi-8u for emacs-devel@gnu.org; Fri, 27 Sep 2013 09:11:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPXpU-00019B-8n for emacs-devel@gnu.org; Fri, 27 Sep 2013 09:11:38 -0400 Original-Received: from ptmx.org ([178.63.28.110]:56111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPXpT-000194-JO for emacs-devel@gnu.org; Fri, 27 Sep 2013 09:11:31 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by ptmx.org (Postfix) with ESMTP id 32E482AA76; Fri, 27 Sep 2013 15:11:31 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at ptmx.org Original-Received: from ptmx.org ([127.0.0.1]) by localhost (ptmx.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dWovcXg7Zfjv; Fri, 27 Sep 2013 15:11:29 +0200 (CEST) Original-Received: from descartes.localnet (chello080108246092.7.14.vie.surfer.at [80.108.246.92]) by ptmx.org (Postfix) with ESMTPSA id 72F3926A34; Fri, 27 Sep 2013 15:11:29 +0200 (CEST) User-Agent: KMail/4.10.5 (Linux/3.8.0-30-generic; KDE/4.10.5; x86_64; ; ) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 178.63.28.110 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:163674 Archived-At: It searches help strings ("lookfor") of octave functions. * lisp/progmodes/octave.el (octave-mode-map): Add key binding for `octave-apropos'. (octave-mode-menu): Add menu entry for `octave-apropos'. (inferior-octave-mode-map): Add key binding for `octave-apropos'. (octave-help-mode-map): Add key binding for `octave-apropos'. (octave-apropos): New function. (octave-lookfor): New alias. Signed-off-by: R=C3=BCdiger Sonderfeld --- lisp/progmodes/octave.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el index c5710b8..ba500d6 100644 --- a/lisp/progmodes/octave.el +++ b/lisp/progmodes/octave.el @@ -109,6 +109,7 @@ (defvar octave-mode-map (define-key map "\C-c/" 'smie-close-block) (define-key map "\C-c;" 'octave-update-function-file-comment) (define-key map "\C-hd" 'octave-help) + (define-key map "\C-ha" 'octave-apropos) (define-key map "\C-c\C-f" 'octave-insert-defun) (define-key map "\C-c\C-il" 'octave-send-line) (define-key map "\C-c\C-ib" 'octave-send-block) @@ -145,6 +146,7 @@ (easy-menu-define octave-mode-menu octave-mode-map ["Start Octave Process" run-octave t] ["Documentation Lookup" info-lookup-symbol t] ["Help on Function" octave-help t] + ["Search help" octave-apropos t] ["Find Function Definition" octave-find-definition t] ["Insert Function" octave-insert-defun t] ["Update Function File Comment" octave-update-function-file-commen= t t] @@ -637,6 +639,7 @@ (defvar inferior-octave-mode-map (define-key map "\M-." 'octave-find-definition) (define-key map "\t" 'completion-at-point) (define-key map "\C-hd" 'octave-help) + (define-key map "\C-ha" 'octave-apropos) ;; Same as in `shell-mode'. (define-key map "\M-?" 'comint-dynamic-list-filename-completions) (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-rin= g) @@ -1607,6 +1610,7 @@ (defvar octave-help-mode-map (let ((map (make-sparse-keymap))) (define-key map "\M-." 'octave-find-definition) (define-key map "\C-hd" 'octave-help) + (define-key map "\C-ha" 'octave-apropos) map)) =20 (define-derived-mode octave-help-mode help-mode "OctHelp" @@ -1685,6 +1689,34 @@ (defun octave-help (fn) :type 'octave-help-function))))) (octave-help-mode))))) =20 +(defun octave-apropos (str &optional all) + "Search for the string STR in all function help strings. +If ALL is non-nil search the entire help string else only search the f= irst +sentence." + (interactive "sSearch for: \nP") + (inferior-octave-send-list-and-digest + (list (format "lookfor (%s'%s');\n" + (if all "'-all', " "") + str))) + (let ((lines inferior-octave-output-list) + (inhibit-read-only t)) + (when (string-match "error: \\(.*\\)$" (car lines)) + (error "%s" (match-string 1 (car lines)))) + (with-help-window octave-help-buffer + (princ (mapconcat 'identity lines "\n")) + (with-current-buffer octave-help-buffer + ;; Bound to t so that `help-buffer' returns current buffer for= + ;; `help-setup-xref'. + (let ((help-xref-following t)) + (help-setup-xref (list 'octave-apropos str all) + (called-interactively-p 'interactive))) + (goto-char (point-min)) + (while (re-search-forward "^\\([^[:blank:]]+\\) " nil 'noerror= ) + (make-text-button (match-beginning 1) (match-end 1) + :type 'octave-help-function)) + (octave-help-mode))))) +(defalias 'octave-lookfor #'octave-apropos) + (defcustom octave-source-directories nil "A list of directories for Octave sources. If the environment variable OCTAVE_SRCDIR is set, it is searched first= ." --=20 1.8.4