X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/33017fafd17d722e82a268e9b272f27df261e09d..e4adb6cdf30706f28dada8aafd347549c84105ac:/lisp/tutorial.el diff --git a/lisp/tutorial.el b/lisp/tutorial.el index e0e2a82fab..4ca01e72b1 100644 --- a/lisp/tutorial.el +++ b/lisp/tutorial.el @@ -1,8 +1,8 @@ ;;; tutorial.el --- tutorial for Emacs -;; Copyright (C) 2006-2012 Free Software Foundation, Inc. +;; Copyright (C) 2006-2016 Free Software Foundation, Inc. -;; Maintainer: FSF +;; Maintainer: emacs-devel@gnu.org ;; Keywords: help, internal ;; Package: emacs @@ -63,8 +63,8 @@ with default Emacs bindings information about this is shown. VALUE should have either of these formats: - \(cua-mode) - \(current-binding KEY-FUN DEF-FUN KEY WHERE) + (cua-mode) + (current-binding KEY-FUN DEF-FUN KEY WHERE) Where KEY is a key sequence whose standard binding has been changed @@ -134,21 +134,20 @@ options: (eq map (symbol-value s)) ;; then save this value in mapsym (setq mapsym s))))) - (insert "The default Emacs binding for the key " - (key-description key) - " is the command `") - (insert (format "%s" db)) - (insert "'. " - "However, your customizations have " + (insert + (format-message + "The default Emacs binding for the key %s is the command `%s'. " + (key-description key) + db)) + (insert "However, your customizations have " (if cb - (format "rebound it to the command `%s'" cb) + (format-message "rebound it to the command `%s'" cb) "unbound it")) (insert ".") (when mapsym (insert " (For the more advanced user:" - " This binding is in the keymap `" - (format "%s" mapsym) - "'.)")) + (format-message + " This binding is in the keymap `%s'.)" mapsym))) (if (string= where "") (unless (keymapp db) (insert "\n\nYou can use M-x " @@ -156,13 +155,11 @@ options: " 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 - " to get the function `" - (format "%s" db) - "'."))) + (format-message " to get the function `%s'." db)))) (fill-region (point-min) (point))))) (help-print-return-message)))) @@ -209,10 +206,10 @@ LEFT and RIGHT are the elements to compare." (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]) @@ -346,10 +343,8 @@ from the Emacs default:\n\n" ) (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) @@ -407,8 +402,8 @@ where REMARK is a list with info about rebinding. It has either of these formats: - \(TEXT cua-mode) - \(TEXT current-binding KEY-FUN DEF-FUN KEY WHERE) + (TEXT cua-mode) + (TEXT current-binding KEY-FUN DEF-FUN KEY WHERE) Here TEXT is a link text to show to the user. The rest of the list is used to show information when @@ -456,7 +451,7 @@ where (lookup-key global-map [menu-bar])))) (stringp cwhere)) - (format "the `%s' menu" cwhere) + (format-message "the `%s' menu" cwhere) "the menus")))) (setq where "")) (setq remark nil) @@ -550,7 +545,11 @@ with some explanatory links." (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)))) @@ -723,9 +722,7 @@ See `tutorial--save-tutorial' for more information." saved-file (error-message-string err)))) ;; An error is raised here?? Is this a bug? - (condition-case nil - (undo-only) - (error nil)) + (ignore-errors (undo-only)) ;; Restore point (goto-char old-point) (if save-err @@ -765,14 +762,13 @@ Run the Viper tutorial? ")) (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)) @@ -829,10 +825,10 @@ Run the Viper tutorial? ")) (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)) - ;; FIXME? What we actually want is to ignore dir-locals (?). - (setq buffer-read-only nil) ; bug#11118 (goto-char (point-min)) (setq old-tut-point (string-to-number @@ -848,10 +844,10 @@ Run the Viper tutorial? ")) (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)) - ;; FIXME? What we actually want is to ignore dir-locals (?). - (setq buffer-read-only nil) ; bug#11118 (forward-line) (setq tutorial--point-before-chkeys (point-marker))) @@ -882,7 +878,7 @@ Run the Viper tutorial? ")) ;; 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 "<>") (replace-match "[Middle of page left blank for didactic purposes. Text continues below]")) @@ -897,7 +893,7 @@ Run the Viper tutorial? ")) ;; 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)