diff options
| author | Stefan Monnier | 2008-04-30 08:48:02 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-04-30 08:48:02 +0000 |
| commit | 5d8137abac262ce380105a6d2c38783e07c2f4e1 (patch) | |
| tree | 6fb2964c9fbf8a3a7ae3d290cdb2987206c32870 /lisp/progmodes | |
| parent | af36f8ed1fd19b523469a2530923b1d2accceb32 (diff) | |
| download | emacs-5d8137abac262ce380105a6d2c38783e07c2f4e1.tar.gz emacs-5d8137abac262ce380105a6d2c38783e07c2f4e1.zip | |
* progmodes/octave-mod.el (octave-help): New function.
* progmodes/octave-hlp.el: Delete.
* info-look.el (octave-mode): Add operator index.
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/octave-hlp.el | 139 | ||||
| -rw-r--r-- | lisp/progmodes/octave-mod.el | 20 |
2 files changed, 10 insertions, 149 deletions
diff --git a/lisp/progmodes/octave-hlp.el b/lisp/progmodes/octave-hlp.el deleted file mode 100644 index 314a3446075..00000000000 --- a/lisp/progmodes/octave-hlp.el +++ /dev/null | |||
| @@ -1,139 +0,0 @@ | |||
| 1 | ;;; octave-hlp.el --- getting help on Octave symbols using info | ||
| 2 | |||
| 3 | ;; Copyright (C) 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 | ||
| 4 | ;; Free Software Foundation, Inc. | ||
| 5 | |||
| 6 | ;; Author: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> | ||
| 7 | ;; Author: John Eaton <jwe@bevo.che.wisc.edu> | ||
| 8 | ;; Maintainer: Kurt Hornik <Kurt.Hornik@wu-wien.ac.at> | ||
| 9 | ;; Keywords: languages | ||
| 10 | |||
| 11 | ;; This file is part of GNU Emacs. | ||
| 12 | |||
| 13 | ;; GNU Emacs is free software; you can redistribute it and/or modify | ||
| 14 | ;; it under the terms of the GNU General Public License as published by | ||
| 15 | ;; the Free Software Foundation; either version 3, or (at your option) | ||
| 16 | ;; any later version. | ||
| 17 | |||
| 18 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 21 | ;; GNU General Public License for more details. | ||
| 22 | |||
| 23 | ;; You should have received a copy of the GNU General Public License | ||
| 24 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | ||
| 25 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| 26 | ;; Boston, MA 02110-1301, USA. | ||
| 27 | |||
| 28 | ;;; Commentary: | ||
| 29 | |||
| 30 | ;; Provides the command `octave-help' which allows index lookup of a | ||
| 31 | ;; symbol in the Octave-related info files, as specified by the list | ||
| 32 | ;; `octave-help-files'. | ||
| 33 | |||
| 34 | ;; Other features may be added in future versions. | ||
| 35 | |||
| 36 | ;;; Code: | ||
| 37 | |||
| 38 | (require 'octave-mod) | ||
| 39 | (require 'info) | ||
| 40 | |||
| 41 | (defvar octave-help-files '("octave") | ||
| 42 | "List of info files with documentation for Octave. | ||
| 43 | Default is (\"octave\").") | ||
| 44 | |||
| 45 | (defvar octave-help-lookup-alist nil | ||
| 46 | "Alist of Octave index entries for lookup.") | ||
| 47 | |||
| 48 | (defvar octave-help-completion-alist nil | ||
| 49 | "Alist of Octave index entries for completion. | ||
| 50 | The entries are of the form (VAR . VAR), where VAR runs through all | ||
| 51 | different keys in `octave-help-lookup-alist'.") | ||
| 52 | |||
| 53 | ;;;###autoload | ||
| 54 | (defun octave-help (key) | ||
| 55 | "Get help on Octave symbols from the Octave info files. | ||
| 56 | Look up KEY in the function, operator and variable indices of the files | ||
| 57 | specified by `octave-help-files'. | ||
| 58 | If KEY is not a string, prompt for it with completion." | ||
| 59 | (interactive | ||
| 60 | (list | ||
| 61 | (completing-read (format "Describe Octave symbol: ") | ||
| 62 | (octave-help-get-completion-alist) | ||
| 63 | nil t))) | ||
| 64 | (if (get-buffer "*info*") | ||
| 65 | (set-buffer "*info*")) | ||
| 66 | (if (zerop (length key)) | ||
| 67 | (Info-find-node (car octave-help-files) "Top") | ||
| 68 | (let ((alist (copy-alist (octave-help-get-lookup-alist))) | ||
| 69 | entry matches) | ||
| 70 | (while (setq entry (car alist)) | ||
| 71 | (if (string-match key (car entry)) | ||
| 72 | (add-to-list 'matches entry)) | ||
| 73 | (setq alist (cdr alist))) | ||
| 74 | (if matches | ||
| 75 | (progn | ||
| 76 | (setq Info-index-alternatives matches) | ||
| 77 | (Info-index-next 0)))))) | ||
| 78 | |||
| 79 | (defun octave-help-get-lookup-alist () | ||
| 80 | "Build the index lookup alist from all Octave info files. | ||
| 81 | The files specified by `octave-help-files' are searched." | ||
| 82 | (if octave-help-lookup-alist | ||
| 83 | () | ||
| 84 | (message "Building help lookup alist...") | ||
| 85 | (let ((files octave-help-files) file key node) | ||
| 86 | (save-window-excursion | ||
| 87 | (while files | ||
| 88 | (setq file (car files)) | ||
| 89 | (Info-goto-node (concat "(" file ")")) | ||
| 90 | (condition-case nil | ||
| 91 | (progn | ||
| 92 | (Info-index "") | ||
| 93 | (while | ||
| 94 | (progn | ||
| 95 | (while (re-search-forward | ||
| 96 | "^\\* \\([^(:]+\\)[^:]*: *\\(.+\\)\\.$" | ||
| 97 | nil t) | ||
| 98 | (setq key (match-string 1) | ||
| 99 | node (concat "(" file ")" (match-string 2))) | ||
| 100 | (and (string-match "\\(.*\\>\\) *$" key) | ||
| 101 | (setq key (replace-match "\\1" t nil key))) | ||
| 102 | (add-to-list 'octave-help-lookup-alist | ||
| 103 | (list key | ||
| 104 | node | ||
| 105 | (concat (concat "(" file ")") | ||
| 106 | Info-current-node) | ||
| 107 | 0))) | ||
| 108 | (and (setq node (Info-extract-pointer "next" t)) | ||
| 109 | (string-match | ||
| 110 | (concat "\\(Function\\|Operator\\|Variable\\) " | ||
| 111 | "\\<Index\\>") | ||
| 112 | node))) | ||
| 113 | (Info-goto-node node))) | ||
| 114 | (error nil)) | ||
| 115 | (setq files (cdr files))))) | ||
| 116 | (message "Building help lookup alist...done")) | ||
| 117 | octave-help-lookup-alist) | ||
| 118 | |||
| 119 | (defun octave-help-get-completion-alist () | ||
| 120 | "Build the index completion alist from all Octave info files. | ||
| 121 | The files specified by `octave-help-files' are searched." | ||
| 122 | (if octave-help-completion-alist | ||
| 123 | () | ||
| 124 | (message "Building help completion alist...") | ||
| 125 | (let ((alist (octave-help-get-lookup-alist)) entry) | ||
| 126 | (while alist | ||
| 127 | (setq entry (car alist)) | ||
| 128 | (add-to-list 'octave-help-completion-alist | ||
| 129 | (cons (car entry) (car entry))) | ||
| 130 | (setq alist (cdr alist)))) | ||
| 131 | (message "Building help completion alist...done")) | ||
| 132 | octave-help-completion-alist) | ||
| 133 | |||
| 134 | ;;; provide ourself | ||
| 135 | |||
| 136 | (provide 'octave-hlp) | ||
| 137 | |||
| 138 | ;; arch-tag: df5ef8fa-76c9-44e5-9835-cb5a502c6282 | ||
| 139 | ;;; octave-hlp.el ends here | ||
diff --git a/lisp/progmodes/octave-mod.el b/lisp/progmodes/octave-mod.el index 2619c48bf11..ce18a7032d7 100644 --- a/lisp/progmodes/octave-mod.el +++ b/lisp/progmodes/octave-mod.el | |||
| @@ -31,13 +31,10 @@ | |||
| 31 | ;; It defines Octave mode, a major mode for editing | 31 | ;; It defines Octave mode, a major mode for editing |
| 32 | ;; Octave code. | 32 | ;; Octave code. |
| 33 | 33 | ||
| 34 | ;; The file octave-hlp.el provides `octave-help', a facility for looking up | ||
| 35 | ;; documentation on a symbol in the Octave info files. | ||
| 36 | |||
| 37 | ;; The file octave-inf.el contains code for interacting with an inferior | 34 | ;; The file octave-inf.el contains code for interacting with an inferior |
| 38 | ;; Octave process using comint. | 35 | ;; Octave process using comint. |
| 39 | 36 | ||
| 40 | ;; See the documentation of `octave-mode', `octave-help' and | 37 | ;; See the documentation of `octave-mode' and |
| 41 | ;; `run-octave' for further information on usage and customization. | 38 | ;; `run-octave' for further information on usage and customization. |
| 42 | 39 | ||
| 43 | ;;; Code: | 40 | ;;; Code: |
| @@ -544,6 +541,12 @@ including a reproducible test case and send the message." | |||
| 544 | (octave-add-octave-menu) | 541 | (octave-add-octave-menu) |
| 545 | (octave-initialize-completions) | 542 | (octave-initialize-completions) |
| 546 | (run-mode-hooks 'octave-mode-hook)) | 543 | (run-mode-hooks 'octave-mode-hook)) |
| 544 | |||
| 545 | (defun octave-help () | ||
| 546 | "Get help on Octave symbols from the Octave info files. | ||
| 547 | Look up symbol in the function, operator and variable indices of the info files." | ||
| 548 | (let ((info-lookup-mode 'octave-mode)) | ||
| 549 | (call-interactively 'info-lookup-symbol))) | ||
| 547 | 550 | ||
| 548 | ;;; Miscellaneous useful functions | 551 | ;;; Miscellaneous useful functions |
| 549 | (defun octave-describe-major-mode () | 552 | (defun octave-describe-major-mode () |
| @@ -1259,8 +1262,7 @@ variables." | |||
| 1259 | (display-completion-list list string)) | 1262 | (display-completion-list list string)) |
| 1260 | (message "Hit space to flush") | 1263 | (message "Hit space to flush") |
| 1261 | (let (key first) | 1264 | (let (key first) |
| 1262 | (if (save-excursion | 1265 | (if (with-current-buffer (get-buffer "*Completions*") |
| 1263 | (set-buffer (get-buffer "*Completions*")) | ||
| 1264 | (setq key (read-key-sequence nil) | 1266 | (setq key (read-key-sequence nil) |
| 1265 | first (aref key 0)) | 1267 | first (aref key 0)) |
| 1266 | (and (consp first) (consp (event-start first)) | 1268 | (and (consp first) (consp (event-start first)) |
| @@ -1427,8 +1429,7 @@ entered without parens)." | |||
| 1427 | (let ((proc inferior-octave-process) | 1429 | (let ((proc inferior-octave-process) |
| 1428 | (string (buffer-substring-no-properties beg end)) | 1430 | (string (buffer-substring-no-properties beg end)) |
| 1429 | line) | 1431 | line) |
| 1430 | (save-excursion | 1432 | (with-current-buffer inferior-octave-buffer |
| 1431 | (set-buffer inferior-octave-buffer) | ||
| 1432 | (setq inferior-octave-output-list nil) | 1433 | (setq inferior-octave-output-list nil) |
| 1433 | (while (not (string-equal string "")) | 1434 | (while (not (string-equal string "")) |
| 1434 | (if (string-match "\n" string) | 1435 | (if (string-match "\n" string) |
| @@ -1517,12 +1518,11 @@ code line." | |||
| 1517 | 'octave-comment-char | 1518 | 'octave-comment-char |
| 1518 | 'octave-continuation-offset | 1519 | 'octave-continuation-offset |
| 1519 | 'octave-continuation-string | 1520 | 'octave-continuation-string |
| 1520 | 'octave-help-files | ||
| 1521 | 'octave-send-echo-input | 1521 | 'octave-send-echo-input |
| 1522 | 'octave-send-line-auto-forward | 1522 | 'octave-send-line-auto-forward |
| 1523 | 'octave-send-show-buffer)))) | 1523 | 'octave-send-show-buffer)))) |
| 1524 | 1524 | ||
| 1525 | ;;; provide ourself | 1525 | ;; provide ourself |
| 1526 | 1526 | ||
| 1527 | (provide 'octave-mod) | 1527 | (provide 'octave-mod) |
| 1528 | 1528 | ||