Commit 5af5ed08 authored by Rüdiger Sonderfeld's avatar Rüdiger Sonderfeld Committed by Leo Liu
Browse files

* lisp/progmodes/octave.el (octave-mode-map): Add key binding for

octave-lookfor.
(octave-mode-menu): Add octave-lookfor.
(inferior-octave-mode-map, octave-help-mode-map): Bind C-ha to
octave-lookfor.
(octave-lookfor): New function.
parent 25201ef0
2013-09-28 Rüdiger Sonderfeld <ruediger@c-plusplus.de>
* lisp/progmodes/octave.el (octave-mode-map): Add key binding for
octave-lookfor.
(octave-mode-menu): Add octave-lookfor.
(inferior-octave-mode-map, octave-help-mode-map): Bind C-ha to
octave-lookfor.
(octave-lookfor): New function.
2013-09-28 Stefan Monnier <monnier@iro.umontreal.ca> 2013-09-28 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/cl-macs.el: * emacs-lisp/cl-macs.el:
......
...@@ -109,6 +109,7 @@ parenthetical grouping.") ...@@ -109,6 +109,7 @@ parenthetical grouping.")
(define-key map "\C-c/" 'smie-close-block) (define-key map "\C-c/" 'smie-close-block)
(define-key map "\C-c;" 'octave-update-function-file-comment) (define-key map "\C-c;" 'octave-update-function-file-comment)
(define-key map "\C-hd" 'octave-help) (define-key map "\C-hd" 'octave-help)
(define-key map "\C-ha" 'octave-lookfor)
(define-key map "\C-c\C-f" 'octave-insert-defun) (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-il" 'octave-send-line)
(define-key map "\C-c\C-ib" 'octave-send-block) (define-key map "\C-c\C-ib" 'octave-send-block)
...@@ -143,6 +144,7 @@ parenthetical grouping.") ...@@ -143,6 +144,7 @@ parenthetical grouping.")
["Start Octave Process" run-octave t] ["Start Octave Process" run-octave t]
["Documentation Lookup" info-lookup-symbol t] ["Documentation Lookup" info-lookup-symbol t]
["Help on Function" octave-help t] ["Help on Function" octave-help t]
["Search help" octave-lookfor t]
["Find Function Definition" octave-find-definition t] ["Find Function Definition" octave-find-definition t]
["Insert Function" octave-insert-defun t] ["Insert Function" octave-insert-defun t]
["Update Function File Comment" octave-update-function-file-comment t] ["Update Function File Comment" octave-update-function-file-comment t]
...@@ -634,6 +636,7 @@ mode, include \"-q\" and \"--traditional\"." ...@@ -634,6 +636,7 @@ mode, include \"-q\" and \"--traditional\"."
(define-key map "\M-." 'octave-find-definition) (define-key map "\M-." 'octave-find-definition)
(define-key map "\t" 'completion-at-point) (define-key map "\t" 'completion-at-point)
(define-key map "\C-hd" 'octave-help) (define-key map "\C-hd" 'octave-help)
(define-key map "\C-ha" 'octave-lookfor)
;; Same as in `shell-mode'. ;; Same as in `shell-mode'.
(define-key map "\M-?" 'comint-dynamic-list-filename-completions) (define-key map "\M-?" 'comint-dynamic-list-filename-completions)
(define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring) (define-key map "\C-c\C-l" 'inferior-octave-dynamic-list-input-ring)
...@@ -1599,6 +1602,7 @@ code line." ...@@ -1599,6 +1602,7 @@ code line."
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(define-key map "\M-." 'octave-find-definition) (define-key map "\M-." 'octave-find-definition)
(define-key map "\C-hd" 'octave-help) (define-key map "\C-hd" 'octave-help)
(define-key map "\C-ha" 'octave-lookfor)
map)) map))
(define-derived-mode octave-help-mode help-mode "OctHelp" (define-derived-mode octave-help-mode help-mode "OctHelp"
...@@ -1677,6 +1681,32 @@ code line." ...@@ -1677,6 +1681,32 @@ code line."
:type 'octave-help-function))))) :type 'octave-help-function)))))
(octave-help-mode))))) (octave-help-mode)))))
(defun octave-lookfor (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 first
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))
(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-lookfor 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)))))
(defcustom octave-source-directories nil (defcustom octave-source-directories nil
"A list of directories for Octave sources. "A list of directories for Octave sources.
If the environment variable OCTAVE_SRCDIR is set, it is searched first." If the environment variable OCTAVE_SRCDIR is set, it is searched first."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment