(setq view-no-disable-on-exit t)
(run-hooks 'help-mode-hook))
+(defun help-mode-maybe ()
+ (if (eq major-mode 'fundamental-mode)
+ (help-mode)))
+
+(add-hook 'temp-buffer-show-hook 'help-mode-maybe)
+
(defun help-quit ()
(interactive)
nil)
+(defvar help-with-tutorial-alist
+ '(("German" . "TUTORIAL.de")
+ ("Korean" . "TUTORIAL.kr")
+ ("Japanese" . "TUTORIAL.jp")
+ ("Thai" . "TUTORIAL.th")
+ ("English" . "TUTORIAL"))
+ "Alist mapping language names to their translated Emacs tutorial files.")
+
(defun help-with-tutorial (&optional arg)
"Select the Emacs learn-by-doing tutorial.
If there is a tutorial version written in the language
of the selected language environment, that version is used.
If there's no tutorial in that language, `TUTORIAL' is selected.
-With arg, you are asked to select which language."
+With arg, you are asked to choose which language."
(interactive "P")
(let (lang filename file)
(if arg
- (or (setq lang (read-language-name 'tutorial "Language: "))
- (error "No tutorial file of the specified language"))
+ (or (setq lang
+ (let* ((completion-ignore-case t))
+ (completing-read "Language: " help-with-tutorial-alist
+ nil t)))
+ (error "No tutorial file in language"))
(setq lang current-language-environment))
- (setq filename (or (get-language-info lang 'tutorial)
+ (setq filename (or (cdr (assoc lang help-with-tutorial-alist))
"TUTORIAL"))
(setq file (expand-file-name (concat "~/" filename)))
(delete-other-windows)
(progn (terpri)
(princ doc))
(princ "not documented")))
- (save-excursion
- (set-buffer standard-output)
- (help-mode))
(print-help-return-message)))))))
(defun describe-mode ()
(princ mode-name)
(princ " mode:\n")
(princ (documentation major-mode))
- (save-excursion
- (set-buffer standard-output)
- (help-mode))
(print-help-return-message)))
;; So keyboard macro definitions are documented correctly
(goto-char (point-min))
(while (progn (move-to-column 50) (not (eobp)))
(search-forward " " nil t)
- (insert "\n"))
- (help-mode))
+ (insert "\n")))
(print-help-return-message)))
(defalias 'help 'help-for-help)
L describe-language-environment. This describes either the a
specific language environment (if you type its name)
or the current language environment (if you type just RET).
-m describe-mode. Print documentation of current major mode,
- which describes the commands peculiar to it.
+m describe-mode. Print documentation of current minor modes,
+ and the current major mode, including their special commands.
n view-emacs-news. Shows emacs news file.
p finder-by-keyword. Find packages matching a given topic keyword.
s describe-syntax. Display contents of syntax table, plus explanations
;; If that gives no function, return a function whose name is around point.
;; If that doesn't give a function, return nil.
(defun function-called-at-point ()
- (or (condition-case ()
- (save-excursion
- (save-restriction
- (narrow-to-region (max (point-min) (- (point) 1000)) (point-max))
- (backward-up-list 1)
- (forward-char 1)
- (let (obj)
- (setq obj (read (current-buffer)))
- (and (symbolp obj) (fboundp obj) obj))))
- (error nil))
- (condition-case ()
- (let ((stab (syntax-table)))
- (unwind-protect
+ (let ((stab (syntax-table)))
+ (set-syntax-table emacs-lisp-mode-syntax-table)
+ (unwind-protect
+ (or (condition-case ()
+ (save-excursion
+ (save-restriction
+ (narrow-to-region (max (point-min) (- (point) 1000)) (point-max))
+ ;; Move up to surrounding paren, then after the open.
+ (backward-up-list 1)
+ (forward-char 1)
+ ;; If there is space here, this is probably something
+ ;; other than a real Lisp function call, so ignore it.
+ (if (looking-at "[ \t]")
+ (error "Probably not a Lisp function call"))
+ (let (obj)
+ (setq obj (read (current-buffer)))
+ (and (symbolp obj) (fboundp obj) obj))))
+ (error nil))
+ (condition-case ()
(save-excursion
- (set-syntax-table emacs-lisp-mode-syntax-table)
(or (not (zerop (skip-syntax-backward "_w")))
(eq (char-syntax (following-char)) ?w)
(eq (char-syntax (following-char)) ?_)
(skip-chars-forward "'")
(let ((obj (read (current-buffer))))
(and (symbolp obj) (fboundp obj) obj)))
- (set-syntax-table stab)))
- (error nil))))
+ (error nil)))
+ (set-syntax-table stab))))
(defun describe-function-find-file (function)
(let ((files load-history)
(setq val (completing-read (if fn
(format "Describe function (default %s): " fn)
"Describe function: ")
- obarray 'fboundp t))
+ obarray 'fboundp t nil nil (symbol-name fn)))
(list (if (equal val "")
fn (intern val)))))
(if function
(princ "'")))
(princ ".")
(terpri)
- (let ((arglist (cond ((byte-code-function-p def)
- (car (append def nil)))
- ((eq (car-safe def) 'lambda)
- (nth 1 def))
+ (let* ((inner-function (if (and (listp def) 'macro)
+ (cdr def)
+ def))
+ (arglist (cond ((byte-code-function-p inner-function)
+ (car (append inner-function nil)))
+ ((eq (car-safe inner-function) 'lambda)
+ (nth 1 inner-function))
(t t))))
(if (listp arglist)
(progn
(print-help-return-message)
(save-excursion
(set-buffer standard-output)
- (help-mode)
;; Return the text we displayed.
(buffer-string)))
(message "You didn't specify a function")))
(setq val (completing-read (if (symbolp v)
(format "Describe variable (default %s): " v)
"Describe variable: ")
- obarray 'boundp t))
+ obarray 'boundp t nil nil
+ (if (symbolp v) (symbol-name v))))
(list (if (equal val "")
v (intern val)))))
(if (symbolp variable)
(print-help-return-message)
(save-excursion
(set-buffer standard-output)
- (help-mode)
;; Return the text we displayed.
(buffer-string))))
(message "You did not specify a variable")))
+(defun describe-bindings (&optional prefix)
+ "Show a list of all defined keys, and their definitions.
+We put that list in a buffer, and display the buffer.
+
+The optional argument PREFIX, if non-nil, should be a key sequence;
+then we display only bindings that start with that prefix."
+ (interactive "p")
+ (describe-bindings-internal nil prefix))
+
(defun where-is (definition &optional insert)
"Print message listing key sequences that invoke specified command.
Argument is a command definition, usually a symbol with a function definition.
(throw 'answer try)))))
(if nosuffix
'("")
- (let ((basic '(".elc" ".el" ""))
- (compressed '(".Z" ".gz" "")))
- ;; If autocompression mode is on,
- ;; consider all combinations of library suffixes
- ;; and compression suffixes.
- (if (rassq 'jka-compr-handler file-name-handler-alist)
- (apply 'nconc
- (mapcar (lambda (compelt)
- (mapcar (lambda (baselt)
- (concat baselt compelt))
- basic))
- compressed))
- basic)))))
+ '(".elc" ".el" "")
+;;; load doesn't handle this yet.
+;;; (let ((basic '(".elc" ".el" ""))
+;;; (compressed '(".Z" ".gz" "")))
+;;; ;; If autocompression mode is on,
+;;; ;; consider all combinations of library suffixes
+;;; ;; and compression suffixes.
+;;; (if (rassq 'jka-compr-handler file-name-handler-alist)
+;;; (apply 'nconc
+;;; (mapcar (lambda (compelt)
+;;; (mapcar (lambda (baselt)
+;;; (concat baselt compelt))
+;;; basic))
+;;; compressed))
+;;; basic))
+ )))
(or path load-path)))
(and interactive-call
(if result