summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/latex2e-help-texinfo/ltx-help.el
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/latex2e-help-texinfo/ltx-help.el')
-rw-r--r--Master/texmf-dist/doc/latex/latex2e-help-texinfo/ltx-help.el182
1 files changed, 97 insertions, 85 deletions
diff --git a/Master/texmf-dist/doc/latex/latex2e-help-texinfo/ltx-help.el b/Master/texmf-dist/doc/latex/latex2e-help-texinfo/ltx-help.el
index 89175d29637..9fefecb88c1 100644
--- a/Master/texmf-dist/doc/latex/latex2e-help-texinfo/ltx-help.el
+++ b/Master/texmf-dist/doc/latex/latex2e-help-texinfo/ltx-help.el
@@ -1,11 +1,11 @@
;;; ltx-help.el --- Lookup latex commands in info pages.
-;; Author: Peter Galbraith <rhogee@bathybius.meteo.mcgill.ca> or <galbrth@ac.dal.ca>
-;; Christian Lynbech <lynbech@daimi.aau.dk>
-;; Martin Sjolin <marsj@ida.liu.se>
-;; Boris Goldowsky <boris@cs.rochester.edu>
-;; Maintainer: Torsten Martinsen <bullestock@dk-online.dk>
-;; Updated: 12 June 2008
+;; Authors: Peter Galbraith <rhogee@bathybius.meteo.mcgill.ca> or <galbrth@ac.dal.ca>
+;; Christian Lynbech <lynbech@daimi.aau.dk>
+;; Martin Sjolin <marsj@ida.liu.se>
+;; Boris Goldowsky <boris@cs.rochester.edu>
+;; Maintainer: as part of latexrefman, http://home.gna.org/latexrefman/
+;; Updated: 25 April 2013
;; Keywords: help, latex, info
@@ -15,10 +15,12 @@
;; environment in the latex online manual. If point is at such a
;; command, this will be the default.
+;; The Texinfo document that this code works with is at
+;; http://ctan.org/pkg/latex2e-help-texinfo.
+
;; Installation:
;;
;; Add the following piece of code to your .emacs
-;;
;; (define-key help-map "\C-l" 'latex-help)
;;
;; to bind latex-help to C-h C-l. To load latex-help when loading AUC-TeX or
@@ -27,19 +29,16 @@
;;
;; (add-hook 'Latex-mode-hook
;; (function (lambda ()
-;; (define-key LaTeX-mode-map "\C-ci" 'latex-help))))
+;; (define-key LaTeX-mode-map "\C-ci" 'latex-help))))
;;
;; or if you do not have add-hook (a very nice package):
;;
;; (setq Latex-mode-hook
-;; (function (lambda ()
-;; (define-key LaTeX-mode-map "\C-ci" 'latex-help))))
+;; (function (lambda ()
+;; (define-key LaTeX-mode-map "\C-ci" 'latex-help))))
;;
;;
-;; The info document that this code works with is at
-;; http://ctan.org/get/info/latex2e-help-texinfo.
-
;;; Change Log:
;;Mar 4, 1994 <lynbech@daimi.aau.dk>:
@@ -79,22 +78,22 @@
;;
;;Mar 29, 1994 <marsj@ida.liu.se>:
;; * made it working under epoch/emacs-18 by calling
-;; completion-read without the last argument.
+;; completion-read without the last argument.
;; * made prompting similar to emacs help
;; * moved add-hook and define keys to installation section, since
-;; the settings conflict with my own keybindings. Also, the key
-;; binding should be chosen by the end user.
+;; the settings conflict with my own keybindings. Also, the key
+;; binding should be chosen by the end user.
;;
-;; Wed Mar 30 08:45:50 1994 LYNBECH
-;; * Changed file layout to conform to FSF's standards
-;; * Tweaked latex-help-guess to include any leading backslashes
-;; * Inversed the meaning of the prefix argument. Now default is
+;; Wed Mar 30 08:45:50 1994 LYNBECH
+;; * Changed file layout to conform to FSF's standards
+;; * Tweaked latex-help-guess to include any leading backslashes
+;; * Inversed the meaning of the prefix argument. Now default is
;; to switch buffers. Also added new variable `latex-help-split-window'
;; to allow window splitting always.
;; * Minor doc fixes
;;
-;; Wed Apr 6 08:34:08 1994 LYNBECH
-;; * fixed latex-help-guess to be more faithful to the lexical rules
+;; Wed Apr 6 08:34:08 1994 LYNBECH
+;; * fixed latex-help-guess to be more faithful to the lexical rules
;; of TeX. The result is not especially elegant.
;;
;;Apr 16, 1994 <abraham@iesd.auc.dk>:
@@ -122,7 +121,14 @@
;; Thu Jun 12 2008 Karl Berry (karl@freefriends.org)
;; Change latex-help-file to "(latex2e)", so our names are consistent.
;; Doc updates.
-;;
+;;
+;; Thu Apr 25 2013 Karl Berry (karl@freefriends.org)
+;; Doc updates, and install these changes:
+;;
+;; Thu Apr 25 2013 Mandar Mitra (mandar.mitra@gmail.com)
+;; Using with (for example) "array" goes to the top node
+;; of latex2e.info instead of the intended node.
+
;;; Code:
(require 'info)
@@ -157,30 +163,36 @@ variable `latex-help-split-window'."
(interactive
(list
(let* ((cw (latex-help-guess))
- (cww (concat "\\" cw))
- (cmd-alist (latex-help-get-cmd-alist))
- (guess (cond ((try-completion cw cmd-alist) cw)
- ((try-completion cww cmd-alist) cww)
- (t nil)))
- (val (completing-read (if guess
- (format "Describe LaTeX command (default %s): " guess)
- "Describe LaTeX command: ")
- cmd-alist nil t nil
- 'latex-help-hist)))
+ (cww (concat "\\" cw))
+ (cmd-alist (latex-help-get-cmd-alist))
+ (node (try-completion cw cmd-alist))
+ ; try-completion returns actual string in case of partial match
+ ; but returns t in case of exact match
+ (nodename1 (if (equal node t) cw node))
+ (nodename2 (if (equal nodename1 nil)
+ (try-completion cww cmd-alist) nodename1))
+ (guess (cond ((equal nodename2 t) cww)
+ ((equal nodename2 nil) nil)
+ (t nodename2)))
+ (val (completing-read (if guess
+ (format "Describe LaTeX command (default %s): " guess)
+ "Describe LaTeX command: ")
+ cmd-alist nil t nil
+ 'latex-help-hist)))
(cdr (assoc (if (equal val "")
- guess
- val) cmd-alist)))
+ guess
+ val) cmd-alist)))
current-prefix-arg))
(if (not (or split latex-help-split-window))
(Info-goto-node (concat latex-help-file cmd))
(save-excursion
(let ((pop-up-windows t)
- (buffer (current-buffer)))
- (pop-to-buffer nil)
- (Info-goto-node (concat latex-help-file cmd))
- (if (fboundp 'show-temp-buffer)
- (show-temp-buffer (current-buffer) t)
- (pop-to-buffer buffer))))))
+ (buffer (current-buffer)))
+ (pop-to-buffer nil)
+ (Info-goto-node (concat latex-help-file cmd))
+ (if (fboundp 'show-temp-buffer)
+ (show-temp-buffer (current-buffer) t)
+ (pop-to-buffer buffer))))))
(defun latex-help-guess ()
"Return the word point is on as a string, if it's between two
@@ -197,44 +209,44 @@ Return the LaTeX command point is on as a string.
;; cl: I am not claiming this to be neither elegant nor fast.
(save-excursion
(let ((oldpoint (point)) (start (point)) (end (point))
- (wc "A-Za-z") (nwc "^A-Za-z"))
+ (wc "A-Za-z") (nwc "^A-Za-z"))
(cond
((looking-at "\\\\[^A-Za-z]")
- (setq start (point)
- end (+ 2 (point))))
+ (setq start (point)
+ end (+ 2 (point))))
((looking-at "\\\\[A-Za-z]+")
- (setq start (match-beginning 0)
- end (match-end 0)))
+ (setq start (match-beginning 0)
+ end (match-end 0)))
(t
- (skip-chars-backward wc)
- (skip-chars-backward "\\\\" (1- (point)))
- (setq start (point))
+ (skip-chars-backward wc)
+ (skip-chars-backward "\\\\" (1- (point)))
+ (setq start (point))
- (goto-char oldpoint)
+ (goto-char oldpoint)
- (skip-chars-forward "\\\\" (1+ (point)))
- (skip-chars-forward wc)
- (setq end (point))
+ (skip-chars-forward "\\\\" (1+ (point)))
+ (skip-chars-forward wc)
+ (setq end (point))
- (if (and (eq start oldpoint) (eq end oldpoint))
- (progn
- (skip-chars-backward nwc
- (save-excursion (beginning-of-line) (point)))
- (if (eq (preceding-char) ?\n)
- (progn
- (skip-chars-forward nwc)
- (setq start (point))
- (skip-chars-forward "\\\\" (1+ (point)))
- (skip-chars-forward wc)
- (setq end (point)))
- (setq end (point))
- (skip-chars-backward wc)
- (skip-chars-backward "\\\\" (1- (point)))
- (setq start (point)))))
- )
+ (if (and (eq start oldpoint) (eq end oldpoint))
+ (progn
+ (skip-chars-backward nwc
+ (save-excursion (beginning-of-line) (point)))
+ (if (eq (preceding-char) ?\n)
+ (progn
+ (skip-chars-forward nwc)
+ (setq start (point))
+ (skip-chars-forward "\\\\" (1+ (point)))
+ (skip-chars-forward wc)
+ (setq end (point)))
+ (setq end (point))
+ (skip-chars-backward wc)
+ (skip-chars-backward "\\\\" (1- (point)))
+ (setq start (point)))))
+ )
)
(ltxh-buffer-substring start end)))
)
@@ -245,22 +257,22 @@ The values are saved in `latex-help-cmd-alist' for speed."
;; mm, does it contain any cached entries
(if (not (assoc "\\begin" latex-help-cmd-alist))
(save-window-excursion
- (setq latex-help-cmd-alist nil)
- (Info-goto-node (concat latex-help-file "Command Index"))
- (if (search-forward "::" nil t)
- (progn
- (end-of-buffer)
- (while (re-search-backward "^\\* \\(.+\\)::$" nil t)
- (setq key (ltxh-buffer-substring (match-beginning 1) (match-end 1)))
- (setq latex-help-cmd-alist
- (cons (cons key key) latex-help-cmd-alist))))
- (end-of-buffer)
- (while (re-search-backward "^\\* \\(.+\\): *\\(.+\\)\\.$" nil t)
- (setq key (ltxh-buffer-substring (match-beginning 1) (match-end 1)))
- (setq value (ltxh-buffer-substring (match-beginning 2) (match-end 2)))
- (setq latex-help-cmd-alist
- (cons (cons key value) latex-help-cmd-alist))))
- ))
+ (setq latex-help-cmd-alist nil)
+ (Info-goto-node (concat latex-help-file "Command Index"))
+ (if (search-forward "::" nil t)
+ (progn
+ (end-of-buffer)
+ (while (re-search-backward "^\\* \\(.+\\)::$" nil t)
+ (setq key (ltxh-buffer-substring (match-beginning 1) (match-end 1)))
+ (setq latex-help-cmd-alist
+ (cons (cons key key) latex-help-cmd-alist))))
+ (end-of-buffer)
+ (while (re-search-backward "^\\* \\(.+\\): *\\(.+\\)\\.$" nil t)
+ (setq key (ltxh-buffer-substring (match-beginning 1) (match-end 1)))
+ (setq value (ltxh-buffer-substring (match-beginning 2) (match-end 2)))
+ (setq latex-help-cmd-alist
+ (cons (cons key value) latex-help-cmd-alist))))
+ ))
;; and return the alist.
latex-help-cmd-alist
)