Mercurial > emacs
comparison lisp/calc/calc-help.el @ 57456:cadf61c7f4eb
(calc-help-function-list, calc-help-variable-list): New variables.
(calc-help-index-entries): New function.
(calc-describe-function): Use calc-help-function-list instead of
obarray for completion.
(calc-describe-variable): Use calc-help-variable-list instead of
obarray for completion.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Tue, 12 Oct 2004 15:47:32 +0000 |
parents | eb0c890a4987 |
children | 5e8a69bc2cfa ff0e824afa37 |
comparison
equal
deleted
inserted
replaced
57455:e23b8a42ded3 | 57456:cadf61c7f4eb |
---|---|
294 (if inv (setq desc (concat "I " desc))) | 294 (if inv (setq desc (concat "I " desc))) |
295 (if hyp (setq desc (concat "H " desc))) | 295 (if hyp (setq desc (concat "H " desc))) |
296 (calc-describe-thing desc "Key Index" nil | 296 (calc-describe-thing desc "Key Index" nil |
297 (string-match "[A-Z][A-Z][A-Z]" desc)))))) | 297 (string-match "[A-Z][A-Z][A-Z]" desc)))))) |
298 | 298 |
299 (defvar calc-help-function-list nil | |
300 "List of functions provided by Calc.") | |
301 | |
302 (defvar calc-help-variable-list nil | |
303 "List of variables provided by Calc.") | |
304 | |
305 (defun calc-help-index-entries (&rest indices) | |
306 "Create a list of entries from the INDICES in the Calc info manual." | |
307 (let ((entrylist '()) | |
308 entry) | |
309 (require 'info nil t) | |
310 (while indices | |
311 (condition-case nil | |
312 (with-temp-buffer | |
313 (Info-mode) | |
314 (Info-goto-node (concat "(Calc)" (car indices) " Index")) | |
315 (goto-char (point-min)) | |
316 (while (re-search-forward "\n\\* \\(.*\\): " nil t) | |
317 (setq entry (match-string 1)) | |
318 (if (and (not (string-match "<[1-9]+>" entry)) | |
319 (not (string-match "(.*)" entry)) | |
320 (not (string= entry "Menu"))) | |
321 (unless (assoc entry entrylist) | |
322 (setq entrylist (cons entry entrylist)))))) | |
323 (error nil)) | |
324 (setq indices (cdr indices))) | |
325 entrylist)) | |
326 | |
299 (defun calc-describe-function (&optional func) | 327 (defun calc-describe-function (&optional func) |
300 (interactive) | 328 (interactive) |
329 (unless calc-help-function-list | |
330 (setq calc-help-function-list | |
331 (calc-help-index-entries "Function" "Command"))) | |
301 (or func | 332 (or func |
302 (setq func (intern (completing-read "Describe function: " | 333 (setq func (completing-read "Describe function: " |
303 obarray nil t "calcFunc-")))) | 334 calc-help-function-list |
304 (setq func (symbol-name func)) | 335 nil t))) |
305 (if (string-match "\\`calc-." func) | 336 (if (string-match "\\`calc-." func) |
306 (calc-describe-thing func "Command Index") | 337 (calc-describe-thing func "Command Index") |
307 (calc-describe-thing (if (string-match "\\`calcFunc-." func) | 338 (calc-describe-thing func "Function Index"))) |
308 (substring func 9) | |
309 func) | |
310 "Function Index"))) | |
311 | 339 |
312 (defun calc-describe-variable (&optional var) | 340 (defun calc-describe-variable (&optional var) |
313 (interactive) | 341 (interactive) |
342 (unless calc-help-variable-list | |
343 (setq calc-help-variable-list | |
344 (calc-help-index-entries "Variable"))) | |
314 (or var | 345 (or var |
315 (setq var (intern (completing-read "Describe variable: " | 346 (setq var (completing-read "Describe variable: " |
316 obarray nil t "var-")))) | 347 calc-help-variable-list |
317 (setq var (symbol-name var)) | 348 nil t))) |
318 (calc-describe-thing var "Variable Index" | 349 (calc-describe-thing var "Variable Index")) |
319 (if (string-match "\\`var-." var) | |
320 (substring var 4) | |
321 var))) | |
322 | 350 |
323 (defun calc-describe-thing (thing where &optional target not-quoted) | 351 (defun calc-describe-thing (thing where &optional target not-quoted) |
324 (message "Looking for `%s' in %s..." thing where) | 352 (message "Looking for `%s' in %s..." thing where) |
325 (let ((savewin (current-window-configuration))) | 353 (let ((savewin (current-window-configuration))) |
326 (calc-info-goto-node where) | 354 (calc-info-goto-node where) |