commit 4b18ef7ba3dd8aae4f3c3bf931365ef7da883baf (HEAD, refs/remotes/origin/master) Author: Katsumi Yamaoka Date: Mon Feb 13 08:30:28 2017 +0000 Fix non-ASCII text encoding (bug#25658) * lisp/gnus/mm-bodies.el (mm-encode-body): Fix non-ASCII text encoding (bug#25658). diff --git a/lisp/gnus/mm-bodies.el b/lisp/gnus/mm-bodies.el index 66b9ebd0cf..d773289722 100644 --- a/lisp/gnus/mm-bodies.el +++ b/lisp/gnus/mm-bodies.el @@ -68,14 +68,14 @@ Valid encodings are `7bit', `8bit', `quoted-printable' and `base64'." (declare-function message-options-set "message" (symbol value)) (defun mm-encode-body (&optional charset) - "Encode a body. -Should be called narrowed to the body that is to be encoded. + "Encode whole buffer's contents. +Buffer's multibyteness will be turned off when encoding takes place. If there is more than one non-ASCII MULE charset in the body, then the list of MULE charsets found is returned. If CHARSET is non-nil, it is used as the MIME charset to encode the body. If successful, the MIME charset is returned. If no encoding was done, nil is returned." - (if (not (mm-multibyte-p)) + (if (not enable-multibyte-characters) ;; In the non-Mule case, we search for non-ASCII chars and ;; return the value of `mail-parse-charset' if any are found. (or charset @@ -93,8 +93,12 @@ If no encoding was done, nil is returned." (save-excursion (if charset (progn - (encode-coding-region (point-min) (point-max) - (mm-charset-to-coding-system charset)) + (insert + (prog1 + (encode-coding-string (buffer-string) + (mm-charset-to-coding-system charset)) + (erase-buffer) + (set-buffer-multibyte nil))) charset) (goto-char (point-min)) (let ((charsets (mm-find-mime-charset-region (point-min) (point-max) @@ -110,8 +114,12 @@ If no encoding was done, nil is returned." (t (prog1 (setq charset (car charsets)) - (encode-coding-region (point-min) (point-max) - (mm-charset-to-coding-system charset)))) + (insert + (prog1 + (encode-coding-string (buffer-string) + (mm-charset-to-coding-system charset)) + (erase-buffer) + (set-buffer-multibyte nil))))) )))))) (defun mm-long-lines-p (length) commit ef6132c55fc3174f67766ad92e5e2866ac92b8ff Author: Glenn Morris Date: Sun Feb 12 19:02:56 2017 -0800 Fix recent bootstrap issue by moving string-to-list * lisp/international/mule-util.el (string-to-list, string-to-vector): Move from here... * lisp/subr.el (string-to-list, string-to-vector): ...to here. The implementation is trivial and at least string-to-list has ended up being needed early during bootstrap. diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index 06b63eae37..92a658655a 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -33,16 +33,6 @@ ;;; String manipulations while paying attention to multibyte characters. ;;;###autoload -(defsubst string-to-list (string) - "Return a list of characters in STRING." - (append string nil)) - -;;;###autoload -(defsubst string-to-vector (string) - "Return a vector of characters in STRING." - (vconcat string)) - -;;;###autoload (defun store-substring (string idx obj) "Embed OBJ (string or character) at index IDX of STRING." (if (integerp obj) diff --git a/lisp/subr.el b/lisp/subr.el index a204577ddf..4f848d1400 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2875,6 +2875,14 @@ See Info node `(elisp)Security Considerations'." (replace-regexp-in-string "[^-0-9a-zA-Z_./\n]" "\\\\\\&" argument)))) )) +(defsubst string-to-list (string) + "Return a list of characters in STRING." + (append string nil)) + +(defsubst string-to-vector (string) + "Return a vector of characters in STRING." + (vconcat string)) + (defun string-or-null-p (object) "Return t if OBJECT is a string or nil. Otherwise, return nil." commit 04ea55fa471f0c75eeee6ccea33cf91c81fc246c Author: Glenn Morris Date: Sun Feb 12 17:53:13 2017 -0800 Doc fixes related to mail-host-address * lisp/startup.el (mail-host-address): Doc fix. * doc/lispref/os.texi (System Environment): Remove extraneous details of mail-host-address. diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 553bb4a006..178822b311 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -940,9 +940,7 @@ string. If this variable is non-@code{nil}, it is used instead of @code{system-name} for purposes of generating email addresses. For example, it is used when constructing the default value of -@code{user-mail-address}. @xref{User Identification}. (Since this is -done when Emacs starts up, the value actually used is the one saved when -Emacs was dumped. @xref{Building Emacs}.) +@code{user-mail-address}. @xref{User Identification}. @c FIXME sounds like should probably give this a :set-after and some @c custom-initialize-delay voodoo. @end defopt diff --git a/lisp/startup.el b/lisp/startup.el index 91e7e36dd6..4272708ce9 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -376,9 +376,8 @@ this variable usefully is to set it while building and dumping Emacs." (make-obsolete-variable 'system-name "use (system-name) instead" "25.1") (defcustom mail-host-address nil - "Name of this machine, for purposes of naming users. -If non-nil, Emacs uses this instead of `system-name' when constructing -email addresses." + "The name of this machine, for use in constructing email addresses. +If this is nil, Emacs uses `system-name'." :type '(choice (const nil) string) :group 'mail) commit e9ec1c5b26139057f85548184ee4b47f3e29f564 Author: Glenn Morris Date: Sun Feb 12 17:44:46 2017 -0800 Simplify time-stamp mail host usage * lisp/time-stamp.el (time-stamp-mail-host-name): Remove function. (time-stamp-string-preprocess): Handle "h" (mail host) directly. diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el index 20b6c3f83b..fa7621bcd4 100644 --- a/lisp/time-stamp.el +++ b/lisp/time-stamp.el @@ -569,7 +569,7 @@ and all `time-stamp-format' compatibility." ((eq cur-char ?L) ;(undocumented alt user full name) (user-full-name)) ((eq cur-char ?h) ;mail host name - (time-stamp-mail-host-name)) + (or mail-host-address (system-name))) ((eq cur-char ?q) ;(undocumented unqual hostname) (let ((qualname (system-name))) (if (string-match "\\." qualname) @@ -639,17 +639,6 @@ Suggests replacing OLD-FORM with NEW-FORM." (insert "\"" old-form "\" -- use " new-form "\n")) (display-buffer "*Time-stamp-compatibility*")))) - - -(defun time-stamp-mail-host-name () - "Return the name of the host where the user receives mail. -This is the value of `mail-host-address' if bound and a string, -otherwise the value of the function `system-name'." - (or (and (boundp 'mail-host-address) - (stringp mail-host-address) - mail-host-address) - (system-name))) - (provide 'time-stamp) ;;; time-stamp.el ends here commit ee9970734facdff57c79811a7b60973a0b9ec6b2 Author: Glenn Morris Date: Sun Feb 12 17:36:33 2017 -0800 Doc fix for vhdl-mode re mail-host-address * lisp/progmodes/vhdl-mode.el (vhdl-file-header): Doc fix. (mail-host-address): Do not add to vhdl-related custom group, since vhdl-template-replace-header-keywords doesn't use it. diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el index 6c76d7e4ad..06ffd54d2d 100644 --- a/lisp/progmodes/vhdl-mode.el +++ b/lisp/progmodes/vhdl-mode.el @@ -1010,7 +1010,7 @@ if the header needs to be version controlled. The following keywords for template generation are supported: : replaced by the name of the buffer : replaced by the user name and email address - (`user-full-name',`mail-host-address', `user-mail-address') + (`user-full-name', `user-mail-address') : replaced by the user full name (`user-full-name') : replaced by user login name (`user-login-name') : replaced by contents of option `vhdl-company-name' @@ -1967,7 +1967,6 @@ are treated as single words otherwise." (unless (featurep 'xemacs) (custom-add-to-group 'vhdl-related 'transient-mark-mode 'custom-variable)) (custom-add-to-group 'vhdl-related 'user-full-name 'custom-variable) -(custom-add-to-group 'vhdl-related 'mail-host-address 'custom-variable) (custom-add-to-group 'vhdl-related 'user-mail-address 'custom-variable) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; commit 4c1d7acf81a4dcec97fa4daf9e9f414e1321bfdb Author: Mark Oteiza Date: Sun Feb 12 20:25:57 2017 -0500 Substitute leading $HOME/ in xdg-user-dirs * lisp/xdg.el (xdg--substitute-home-env): New function. (xdg--user-dirs-parse-line): Use it. (xdg-user-dir): Expand ~/ in xdg-user-dirs values. diff --git a/lisp/xdg.el b/lisp/xdg.el index b11e104e2b..4973065f91 100644 --- a/lisp/xdg.el +++ b/lisp/xdg.el @@ -109,6 +109,12 @@ file:///foo/bar.jpg" (defvar xdg-user-dirs nil "Alist of directory keys and values.") +(defun xdg--substitute-home-env (str) + (if (file-name-absolute-p str) str + (save-match-data + (and (string-match "^$HOME/" str) + (replace-match "~/" t nil str 0))))) + (defun xdg--user-dirs-parse-line () "Return pair of user-dirs key to directory value in LINE, otherwise nil. This should be called at the beginning of a line." @@ -117,7 +123,7 @@ This should be called at the beginning of a line." (looking-at xdg-line-regexp)) (let ((k (match-string 1)) (v (match-string 2))) - (when (and k v) (cons k v))))) + (when (and k v) (cons k (xdg--substitute-home-env v)))))) (defun xdg--user-dirs-parse-file (filename) "Return alist of xdg-user-dirs from FILENAME." @@ -137,7 +143,8 @@ This should be called at the beginning of a line." (setq xdg-user-dirs (xdg--user-dirs-parse-file (expand-file-name "user-dirs.dirs" (xdg-config-home))))) - (cdr (assoc name xdg-user-dirs))) + (let ((dir (cdr (assoc name xdg-user-dirs)))) + (when dir (expand-file-name dir)))) (provide 'xdg) commit 01ebe5dc0b1c71191f6a713fec245a188d587772 Author: Mark Oteiza Date: Sun Feb 12 20:02:26 2017 -0500 * lisp/buff-menu.el: Turn on lexical-binding. diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index 9f618bcb7d..83d6bb6b0e 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -1,4 +1,4 @@ -;;; buff-menu.el --- Interface for viewing and manipulating buffers +;;; buff-menu.el --- Interface for viewing and manipulating buffers -*- lexical-binding: t -*- ;; Copyright (C) 1985-1987, 1993-1995, 2000-2017 Free Software ;; Foundation, Inc. commit d8cca4d8c56a90ec9215d7bfb0b0edfa3a36ad4f Author: Juri Linkov Date: Mon Feb 13 02:37:52 2017 +0200 * lisp/replace.el (query-replace-from-to-separator): Move propertize and char-displayable-p test to query-replace-read-from. Add choice nil to disable this feature. (query-replace-read-from): Don't reevaluate custom setting. Use char-displayable-p to test the first non-whitespace character in query-replace-from-to-separator, use " -> " when fails. Add prompt for the case when separator is nil but query-replace-defaults is non-nil. Remove unused test for regexp-flag. Thanks to Thierry Volpiatto diff --git a/lisp/replace.el b/lisp/replace.el index a825040a97..b96c883982 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -79,15 +79,14 @@ That becomes the \"string to replace\".") to the minibuffer that reads the string to replace, or invoke replacements from Isearch by using a key sequence like `C-s C-s M-%'." "24.3") -(defcustom query-replace-from-to-separator - (propertize (if (char-displayable-p ?→) " → " " -> ") - 'face 'minibuffer-prompt) - "String that separates FROM and TO in the history of replacement pairs." - ;; Avoids error when attempt to autoload char-displayable-p fails - ;; while preparing to dump, also stops customize-rogue listing this. - :initialize 'custom-initialize-delay +(defcustom query-replace-from-to-separator " → " + "String that separates FROM and TO in the history of replacement pairs. +When nil, the pair will not be added to the history (same behavior +as in emacs 24.5)." :group 'matching - :type '(choice string (sexp :tag "Display specification")) + :type '(choice + (const :tag "Disabled" nil) + string) :version "25.1") (defcustom query-replace-from-history-variable 'query-replace-history @@ -165,14 +164,18 @@ The return value can also be a pair (FROM . TO) indicating that the user wants to replace FROM with TO." (if query-replace-interactive (car (if regexp-flag regexp-search-ring search-ring)) - ;; Reevaluating will check char-displayable-p that is - ;; unavailable while preparing to dump. - (custom-reevaluate-setting 'query-replace-from-to-separator) (let* ((history-add-new-input nil) (separator (when query-replace-from-to-separator (propertize "\0" - 'display query-replace-from-to-separator + 'display + (propertize + (if (char-displayable-p + (string-to-char (replace-regexp-in-string + " " "" query-replace-from-to-separator))) + query-replace-from-to-separator + " -> ") + 'face 'minibuffer-prompt) 'separator t))) (minibuffer-history (append @@ -185,9 +188,13 @@ wants to replace FROM with TO." (symbol-value query-replace-from-history-variable))) (minibuffer-allow-text-properties t) ; separator uses text-properties (prompt - (if (and query-replace-defaults separator) - (format "%s (default %s): " prompt (car minibuffer-history)) - (format "%s: " prompt))) + (cond ((and query-replace-defaults separator) + (format "%s (default %s): " prompt (car minibuffer-history))) + (query-replace-defaults + (format "%s (default %s -> %s): " prompt + (query-replace-descr (caar query-replace-defaults)) + (query-replace-descr (cdar query-replace-defaults)))) + (t (format "%s: " prompt)))) (from ;; The save-excursion here is in case the user marks and copies ;; a region in order to specify the minibuffer input. @@ -200,8 +207,7 @@ wants to replace FROM with TO." (if regexp-flag (read-regexp prompt nil 'minibuffer-history) (read-from-minibuffer - prompt nil nil nil nil - (car (if regexp-flag regexp-search-ring search-ring)) t))))) + prompt nil nil nil nil (car search-ring) t))))) (to)) (if (and (zerop (length from)) query-replace-defaults) (cons (caar query-replace-defaults) commit a84da83c1abceb0750e78c48452903729105df09 Author: Karl Fogel Date: Sun Feb 12 17:21:06 2017 -0600 Convert more uses of `looking-at' to `following-char' This follows up to Mark Oteiza's commit of 12 Feb 2017, 14:46:03 UTC (commit 91478f46238a) with more of the same. * lisp/bookmark.el (bookmark-send-edited-annotation): (bookmark-bmenu-execute-deletions): Replace instances of looking-at with char comparisons using following-char. diff --git a/lisp/bookmark.el b/lisp/bookmark.el index ab4363b023..5b8ded7b22 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -957,7 +957,7 @@ Lines beginning with `#' are ignored." (error "Not in bookmark-edit-annotation-mode")) (goto-char (point-min)) (while (< (point) (point-max)) - (if (looking-at "^#") + (if (= (following-char) ?#) (bookmark-kill-line t) (forward-line 1))) ;; Take no chances with text properties. @@ -2064,7 +2064,7 @@ To carry out the deletions that you've marked, use \\\\ (let ((o-point (point)) (o-str (save-excursion (beginning-of-line) - (unless (looking-at "^D") + (unless (= (following-char) ?D) (buffer-substring (point) (progn (end-of-line) (point)))))) commit d4429dfd4975c3a084467fa3b07ac715ed4a2d60 Author: Paul Eggert Date: Sun Feb 12 12:55:11 2017 -0800 Fix typos in tests for lax-plist-get etc. Problem reported by Eli Zaretskii (Bug#25606#62). * test/src/fns-tests.el (test-cycle-lax-plist-get) (test-cycle-plist-put, test-cycle-lax-plist-put): Fix tests to match behavior. diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index 160d0f106e..a1b48a643e 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el @@ -473,12 +473,12 @@ (should (lax-plist-get d2 1)) (should-error (lax-plist-get c1 2) :type 'circular-list) (should (lax-plist-get c2 2)) - (should-not (lax-plist-get d1 2)) + (should-error (lax-plist-get d1 2) :type 'wrong-type-argument) (should (lax-plist-get d2 2)) (should-error (lax-plist-get c1 3) :type 'circular-list) (should-error (lax-plist-get c2 3) :type 'circular-list) - (should-not (lax-plist-get d1 3)) - (should-not (lax-plist-get d2 3)))) + (should-error (lax-plist-get d1 3) :type 'wrong-type-argument) + (should-error (lax-plist-get d2 3) :type 'wrong-type-argument))) (ert-deftest test-cycle-plist-member () (let ((c1 (cyc1 1)) @@ -509,12 +509,12 @@ (should (plist-put d2 1 1)) (should-error (plist-put c1 2 2) :type 'circular-list) (should (plist-put c2 2 2)) - (should (plist-put d1 2 2)) + (should-error (plist-put d1 2 2) :type 'wrong-type-argument) (should (plist-put d2 2 2)) (should-error (plist-put c1 3 3) :type 'circular-list) (should-error (plist-put c2 3 3) :type 'circular-list) - (should (plist-put d1 3 3)) - (should (plist-put d2 3 3)))) + (should-error (plist-put d1 3 3) :type 'wrong-type-argument) + (should-error (plist-put d2 3 3) :type 'wrong-type-argument))) (ert-deftest test-cycle-lax-plist-put () (let ((c1 (cyc1 1)) @@ -527,12 +527,12 @@ (should (lax-plist-put d2 1 1)) (should-error (lax-plist-put c1 2 2) :type 'circular-list) (should (lax-plist-put c2 2 2)) - (should (lax-plist-put d1 2 2)) + (should-error (lax-plist-put d1 2 2) :type 'wrong-type-argument) (should (lax-plist-put d2 2 2)) (should-error (lax-plist-put c1 3 3) :type 'circular-list) (should-error (lax-plist-put c2 3 3) :type 'circular-list) - (should (lax-plist-put d1 3 3)) - (should (lax-plist-put d2 3 3)))) + (should-error (lax-plist-put d1 3 3) :type 'wrong-type-argument) + (should-error (lax-plist-put d2 3 3) :type 'wrong-type-argument))) (ert-deftest test-cycle-equal () (should-error (equal (cyc1 1) (cyc1 1))) commit 0769c9957852236dd913fd617fdbc79ad581341c Author: Michael Albinus Date: Sun Feb 12 18:19:32 2017 +0100 Fix bug#25607 * lisp/net/tramp.el (tramp-completion-file-name-handler): Improve autoloaded version. (tramp-autoload-file-name-handler): Avoid recursive load. (tramp-completion-handle-expand-file-name): Handle empty NAME. (Bug#25607) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 48dcd5edd1..4b5bd47263 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2133,9 +2133,13 @@ preventing reentrant calls of Tramp.") Together with `tramp-locked', this implements a locking mechanism preventing reentrant calls of Tramp.") -;; Avoid recursive loading of tramp.el. +;; Avoid recursive loading of tramp.el. If `non-essential' is +;; non-nil, we must load tramp.el, in order to get the real definition +;; of `tramp-completion-file-name-handler'. ;;;###autoload(defun tramp-completion-file-name-handler (operation &rest args) -;;;###autoload (tramp-completion-run-real-handler operation args)) +;;;###autoload (if (and (boundp 'non-essential) (symbol-value 'non-essential)) +;;;###autoload (apply 'tramp-autoload-file-name-handler operation args) +;;;###autoload (tramp-completion-run-real-handler operation args))) (defun tramp-completion-file-name-handler (operation &rest args) "Invoke Tramp file name completion handler. @@ -2165,9 +2169,11 @@ Falls back to normal file name handler if no Tramp file name handler exists." (progn (defun tramp-autoload-file-name-handler (operation &rest args) "Load Tramp file name handler, and perform OPERATION." ;; Avoid recursive loading of tramp.el. - (let ((default-directory temporary-file-directory)) - (load "tramp" nil t)) - (apply operation args))) + (if (let ((default-directory temporary-file-directory)) + (and (null load-in-progress) (load "tramp" 'noerror 'nomessage))) + (apply operation args) + ;; tramp.el not available for loading, fall back. + (tramp-completion-run-real-handler operation args)))) ;; `tramp-autoload-file-name-handler' must be registered before ;; evaluation of site-start and init files, because there might exist @@ -2307,11 +2313,10 @@ not in completion mode." (progn ;; If DIR is not given, use `default-directory' or "/". (setq dir (or dir default-directory "/")) - ;; Unless NAME is absolute, concat DIR and NAME. - (unless (file-name-absolute-p name) - (setq name (concat (file-name-as-directory dir) name))) - ;; Return NAME. - name) + (cond + ((file-name-absolute-p name) name) + ((zerop (length name)) dir) + (t (concat (file-name-as-directory dir) name)))) (tramp-completion-run-real-handler 'expand-file-name (list name dir)))) commit 7459cbec9547ff5f9d74f9303f4cb95a3d6842dc Author: Mark Oteiza Date: Sun Feb 12 11:51:19 2017 -0500 Remove server-buffer-clients string from minor-mode-alist * lisp/server.el: Don't put an element for server-buffer-clients into minor-mode-alist. (Bug#20201) diff --git a/lisp/server.el b/lisp/server.el index 1d26caef89..209bfaaf70 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -245,10 +245,6 @@ in this way." :type 'boolean :version "21.1") -;; FIXME? This is not a minor mode; what's the point of this? (See bug#20201) -(or (assq 'server-buffer-clients minor-mode-alist) - (push '(server-buffer-clients " Server") minor-mode-alist)) - (defvar server-existing-buffer nil "Non-nil means the buffer existed before the server was asked to visit it. This means that the server should not kill the buffer when you say you commit 91478f46238ab5a0f5fb7e6e6b4b1da0163c596e Author: Mark Oteiza Date: Sun Feb 12 09:46:03 2017 -0500 Nix some useless uses of looking-at, looking-back * lisp/allout.el (allout-kill-topic): (allout-next-topic-pending-encryption): * lisp/bookmark.el (bookmark-kill-line): * lisp/cus-edit.el (custom-save-variables, custom-save-faces): * lisp/cus-theme.el (custom-theme-write-variables): (custom-theme-write-faces): * lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads): * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): * lisp/emacs-lisp/checkdoc.el (checkdoc-interactive-loop): (checkdoc-interactive-ispell-loop): (checkdoc-message-interactive-ispell-loop, checkdoc-this-string-valid): (checkdoc-this-string-valid-engine): * lisp/emacs-lisp/elint.el (elint-get-top-forms): * lisp/emulation/viper-cmd.el (viper-backward-indent): * lisp/image-dired.el (image-dired-delete-char): * lisp/simple.el (kill-visual-line): Replace instances of looking-at, looking-back with char comparisons using following-char, preceding-char. diff --git a/lisp/allout.el b/lisp/allout.el index 4a0aeeedf6..e837f83ed3 100644 --- a/lisp/allout.el +++ b/lisp/allout.el @@ -4462,7 +4462,7 @@ Topic exposure is marked with text-properties, to be used by (if (and (/= (current-column) 0) (not (eobp))) (forward-char 1)) (if (not (eobp)) - (if (and (save-match-data (looking-at "\n")) + (if (and (= (following-char) ?\n) (or (save-excursion (or (not (allout-next-heading)) (= depth allout-recent-depth))) @@ -6278,8 +6278,7 @@ It must also have content." (setq got nil done t) (goto-char (setq got (match-beginning 0))) - (if (save-match-data (looking-at "\n")) - (forward-char 1)) + (when (= (following-char) ?\n) (forward-char 1)) (setq got (point))) (cond ((not got) diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 02dd8a9f6f..ab4363b023 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -896,8 +896,8 @@ If optional arg NEWLINE-TOO is non-nil, delete the newline too. Does not affect the kill ring." (let ((eol (line-end-position))) (delete-region (point) eol) - (if (and newline-too (looking-at "\n")) - (delete-char 1)))) + (when (and newline-too (= (following-char) ?\n)) + (delete-char 1)))) ;; Defvars to avoid compilation warnings: diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 2b86051a72..fac9c77e12 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -4581,7 +4581,7 @@ This function does not save the buffer." (if (bolp) (princ " ")) (princ ")") - (unless (looking-at-p "\n") + (when (/= (following-char) ?\n) (princ "\n"))))) (defun custom-save-faces () @@ -4636,7 +4636,7 @@ This function does not save the buffer." (if (bolp) (princ " ")) (princ ")") - (unless (looking-at-p "\n") + (when (/= (following-char) ?\n) (princ "\n"))))) ;;; The Customize Menu. diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el index c5682add23..d2ee14d8bd 100644 --- a/lisp/cus-theme.el +++ b/lisp/cus-theme.el @@ -431,7 +431,7 @@ It includes all variables in list VARS." (if (bolp) (princ " ")) (princ ")") - (unless (looking-at "\n") + (when (/= (following-char) ?\n) (princ "\n"))))) (defun custom-theme-write-faces (theme faces) @@ -463,7 +463,7 @@ It includes all faces in list FACES." (princ ")"))))) (if (bolp) (princ " ")) (princ ")") - (unless (looking-at "\n") + (when (/= (following-char) ?\n) (princ "\n"))))) diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index ca1d75176d..1b7ff36f42 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -748,7 +748,7 @@ FILE's modification time." (setq output-start (autoload--setup-output otherbuf outbuf absfile load-name))) (autoload--print-cookie-text output-start load-name file)) - ((looking-at ";") + ((= (following-char) ?\;) ;; Don't read the comment. (forward-line 1)) (t diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 63be7e208b..09ea7206d6 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1995,7 +1995,7 @@ With argument ARG, insert value in current buffer after the form." ;; Compile the forms from the input buffer. (while (progn (while (progn (skip-chars-forward " \t\n\^l") - (looking-at ";")) + (= (following-char) ?\;)) (forward-line 1)) (not (eobp))) (setq byte-compile-read-position (point) diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 59edbe100e..1d6fdfa4e8 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -603,7 +603,7 @@ style." (checkdoc-overlay-put cdo 'face 'highlight) ;; Make sure the whole doc string is visible if possible. (sit-for 0) - (if (and (looking-at "\"") + (if (and (= (following-char) ?\") (not (pos-visible-in-window-p (save-excursion (forward-sexp 1) (point)) (selected-window)))) @@ -743,9 +743,9 @@ buffer, otherwise searching starts at START-HERE." (while (checkdoc-next-docstring) (message "Searching for doc string spell error...%d%%" (floor (* 100.0 (point)) (point-max))) - (if (looking-at "\"") - (checkdoc-ispell-docstring-engine - (save-excursion (forward-sexp 1) (point-marker))))) + (when (= (following-char) ?\") + (checkdoc-ispell-docstring-engine + (save-excursion (forward-sexp 1) (point-marker))))) (message "Checkdoc: Done.")))) (defun checkdoc-message-interactive-ispell-loop (start-here) @@ -763,7 +763,7 @@ buffer, otherwise searching starts at START-HERE." (while (checkdoc-message-text-next-string (point-max)) (message "Searching for message string spell error...%d%%" (floor (* 100.0 (point)) (point-max))) - (if (looking-at "\"") + (if (= (following-char) ?\") (checkdoc-ispell-docstring-engine (save-excursion (forward-sexp 1) (point-marker))))) (message "Checkdoc: Done.")))) @@ -1381,7 +1381,7 @@ See the style guide in the Emacs Lisp manual for more details." "All variables and subroutines might as well have a \ documentation string") (point) (+ (point) 1) t))))) - (if (and (not err) (looking-at "\"")) + (if (and (not err) (= (following-char) ?\")) (with-syntax-table checkdoc-syntax-table (checkdoc-this-string-valid-engine fp)) err))) @@ -1395,7 +1395,7 @@ regexp short cuts work. FP is the function defun information." ;; we won't accidentally lose our place. This could cause ;; end-of doc string whitespace to also delete the " char. (s (point)) - (e (if (looking-at "\"") + (e (if (= (following-char) ?\") (save-excursion (forward-sexp 1) (point-marker)) (point)))) (or @@ -1475,7 +1475,7 @@ regexp short cuts work. FP is the function defun information." ((looking-at "[\\!?;:.)]") ;; These are ok nil) - ((and checkdoc-permit-comma-termination-flag (looking-at ",")) + ((and checkdoc-permit-comma-termination-flag (= (following-char) ?,)) nil) (t ;; If it is not a complete sentence, let's see if we can diff --git a/lisp/emacs-lisp/elint.el b/lisp/emacs-lisp/elint.el index d68e49fa4b..f5e10a24d3 100644 --- a/lisp/emacs-lisp/elint.el +++ b/lisp/emacs-lisp/elint.el @@ -372,7 +372,7 @@ Returns the forms." (let ((elint-current-pos (point))) ;; non-list check could be here too. errors may be out of seq. ;; quoted check cannot be elsewhere, since quotes skipped. - (if (looking-back "'" (1- (point))) + (if (= (preceding-char) ?\') ;; Eg cust-print.el uses ' as a comment syntax. (elint-warning "Skipping quoted form `%c%.20s...'" ?\' (read (current-buffer))) diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el index 86364282dc..aa31fac32c 100644 --- a/lisp/emulation/viper-cmd.el +++ b/lisp/emulation/viper-cmd.el @@ -4520,7 +4520,7 @@ One can use \\=`\\=` and \\='\\=' to temporarily jump 1 step back." (interactive) (if viper-cted (let ((p (point)) (c (current-column)) bol (indent t)) - (if (looking-back "[0^]" (1- (point))) + (if (memq (preceding-char) '(?0 ?^)) (progn (if (eq ?^ (preceding-char)) (setq viper-preserve-indent t)) diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 2a4064560a..49dba52c88 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -1751,8 +1751,8 @@ Ask user for number of images to show and the delay in between." (interactive) (let ((inhibit-read-only t)) (delete-char 1) - (if (looking-at " ") - (delete-char 1)))) + (when (= (following-char) ?\s) + (delete-char 1)))) ;;;###autoload (defun image-dired-display-thumbs-append () diff --git a/lisp/simple.el b/lisp/simple.el index c0dad2d36e..f110c6f326 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -6665,7 +6665,7 @@ even beep.)" ;; whether the trailing whitespace is highlighted. But, it's ;; OK to just do this unconditionally. (skip-chars-forward " \t"))) - (kill-region opoint (if (and kill-whole-line (looking-at "\n")) + (kill-region opoint (if (and kill-whole-line (= (following-char) ?\n)) (1+ (point)) (point)))))