;;; tutorial.el --- tutorial for Emacs
-;; Copyright (C) 2006-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2015 Free Software Foundation, Inc.
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
;; Keywords: help, internal
;; Package: emacs
" RET instead."))
(insert "\n\nWith your current key bindings"
" you can use "
- (if (string-match "^the .*menus?$" where)
+ (if (string-match-p "^the .*menus?$" where)
""
"the key")
where
(equal (car x) (car y)))
(setq x (cdr x))
(setq y (cdr y)))
- ;; Try to make a comparision that is useful for presentation (this
+ ;; Try to make a comparison that is useful for presentation (this
;; could be made nicer perhaps):
(let ((cx (car x))
(cy (car y)))
(symbol-name cx)))))))
(defconst tutorial--default-keys
- ;; On window system, `suspend-emacs' is replaced in the default
- ;; keymap
+ ;; On window system, `suspend-emacs' is replaced in the default keymap.
(let* ((suspend-emacs 'suspend-frame)
(default-keys
+ ;; The first few are not mentioned but are basic:
`((ESC-prefix [27])
(Control-X-prefix [?\C-x])
(mode-specific-command-prefix [?\C-c])
(def-fun-txt (nth 2 tk))
(where (nth 3 tk))
(remark (nth 4 tk))
- (rem-fun (command-remapping def-fun))
(key-txt (key-description key))
- (key-fun (with-current-buffer tutorial-buffer (key-binding key)))
- tot-len)
+ (key-fun (with-current-buffer tutorial-buffer (key-binding key))))
(unless (eq def-fun key-fun)
;; Insert key binding description:
(when (string= key-txt explain-key-desc)
(start (point))
(case-fold-search nil)
(keybindings-regexp
- (concat "[[:space:]]\\("
+ ;; Accept either [:space:] or [:punct:] before the key
+ ;; binding because the Hebrew tutorial uses directional
+ ;; controls and Hebrew character maqaf, the Hebrew hyphen,
+ ;; immediately before the binding string.
+ (concat "\\(?:[[:space:]]\\|[[:punct:]]\\)\\("
(mapconcat (lambda (kdf) (regexp-quote
(tutorial--key-description
(nth 1 kdf))))
(not (get-text-property (match-beginning 1) 'tutorial-remark))
(let* ((desc (car changed-key))
(ck (cdr changed-key))
- (key (nth 0 ck))
(def-fun (nth 1 ck))
(where (nth 3 ck))
s1 s2 help-string)
saved-file
(error-message-string err))))
;; An error is raised here?? Is this a bug?
- (condition-case err
- (undo-only)
- (error nil))
+ (ignore-errors (undo-only))
;; Restore point
(goto-char old-point)
(if save-err
(funcall 'viper-tutorial 0))
(message "Tutorial aborted by user"))
(message prompt1)))
- (let* ((lang (if arg
- (let ((minibuffer-setup-hook minibuffer-setup-hook))
- (add-hook 'minibuffer-setup-hook
- 'minibuffer-completion-help)
- (read-language-name 'tutorial "Language: " "English"))
- (if (get-language-info current-language-environment 'tutorial)
- current-language-environment
- "English")))
+ (let* ((lang (cond
+ (arg
+ (minibuffer-with-setup-hook #'minibuffer-completion-help
+ (read-language-name 'tutorial "Language: " "English")))
+ ((get-language-info current-language-environment 'tutorial)
+ current-language-environment)
+ (t "English")))
(filename (get-language-info lang 'tutorial))
(tut-buf-name filename)
(old-tut-buf (get-buffer tut-buf-name))
(if old-tut-file
(progn
(insert-file-contents (tutorial--saved-file))
- (let ((enable-local-variables :safe))
+ (let ((enable-local-variables :safe)
+ (enable-local-eval nil)
+ (enable-dir-local-variables nil)) ; bug#11127
(hack-local-variables))
(goto-char (point-min))
(setq old-tut-point
(goto-char tutorial--point-before-chkeys)
(setq tutorial--point-before-chkeys (point-marker)))
(insert-file-contents (expand-file-name filename tutorial-directory))
- (let ((enable-local-variables :safe))
+ (let ((enable-local-variables :safe)
+ (enable-local-eval nil)
+ (enable-dir-local-variables nil)) ; bug#11127
(hack-local-variables))
(forward-line)
(setq tutorial--point-before-chkeys (point-marker)))
;; or just delete the <<...>> line if a [...] line follows.
(cond ((save-excursion
(forward-line 1)
- (looking-at "\\["))
+ (looking-at-p "\\["))
(delete-region (point) (progn (forward-line 1) (point))))
((looking-at "<<Blank lines inserted.*>>")
(replace-match "[Middle of page left blank for didactic purposes. Text continues below]"))
;; inserted at the start of the buffer, the "type C-v to
;; move to the next screen" might not be visible on the
;; first screen (n < 0). How will the novice know what to do?
- (let ((n (- (window-height (selected-window))
+ (let ((n (- (window-height)
(count-lines (point-min) (point))
6)))
(if (< n 8)