Commit cb410433 authored by Vibhav Pant's avatar Vibhav Pant

Merge branch 'master' into feature/byte-switch

parents e7424504 4b18ef7b
......@@ -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
......@@ -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)
......@@ -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:
......@@ -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 \\<bookmark-bmenu-mode-map>\\
(let ((o-point (point))
(o-str (save-excursion
(unless (looking-at "^D")
(unless (= (following-char) ?D)
(progn (end-of-line) (point))))))
;;; 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.
......@@ -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.
......@@ -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")))))
......@@ -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))
......@@ -2013,7 +2013,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)
......@@ -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))
......@@ -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 "\"")
(save-excursion (forward-sexp 1) (point-marker)))))
(when (= (following-char) ?\")
(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) ?\")
(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))
......@@ -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))
......@@ -1475,7 +1475,7 @@ regexp short cuts work. FP is the function defun information."
((looking-at "[\\!?;:.)]")
;; These are ok
((and checkdoc-permit-comma-termination-flag (looking-at ","))
((and checkdoc-permit-comma-termination-flag (= (following-char) ?,))
;; If it is not a complete sentence, let's see if we can
......@@ -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)))
......@@ -4520,7 +4520,7 @@ One can use \\=`\\=` and \\='\\=' to temporarily jump 1 step back."
(if viper-cted
(let ((p (point)) (c (current-column)) bol (indent t))
(if (looking-back "[0^]" (1- (point)))
(if (memq (preceding-char) '(?0 ?^))
(if (eq ?^ (preceding-char))
(setq viper-preserve-indent t))
......@@ -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."
(if charset
(encode-coding-region (point-min) (point-max)
(mm-charset-to-coding-system charset))
(encode-coding-string (buffer-string)
(mm-charset-to-coding-system charset))
(set-buffer-multibyte nil)))
(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."
(setq charset (car charsets))
(encode-coding-region (point-min) (point-max)
(mm-charset-to-coding-system charset))))
(encode-coding-string (buffer-string)
(mm-charset-to-coding-system charset))
(set-buffer-multibyte nil)))))
(defun mm-long-lines-p (length)
......@@ -1751,8 +1751,8 @@ Ask user for number of images to show and the delay in between."
(let ((inhibit-read-only t))
(delete-char 1)
(if (looking-at " ")
(delete-char 1))))
(when (= (following-char) ?\s)
(delete-char 1))))
(defun image-dired-display-thumbs-append ()
......@@ -32,16 +32,6 @@
;;; String manipulations while paying attention to multibyte characters.
(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 store-substring (string idx obj)
"Embed OBJ (string or character) at index IDX of STRING."
......@@ -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."
;; 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.
((file-name-absolute-p name) name)
((zerop (length name)) dir)
(t (concat (file-name-as-directory dir) name))))
'expand-file-name (list name dir))))
......@@ -1687,29 +1687,36 @@ This performs fontification according to `js--class-styles'."
"Font lock keywords for `js-mode'. See `font-lock-keywords'.")
(defconst js--syntax-propertize-regexp-syntax-table
(let ((st (make-char-table 'syntax-table (string-to-syntax "."))))
(modify-syntax-entry ?\[ "(]" st)
(modify-syntax-entry ?\] ")[" st)
(modify-syntax-entry ?\\ "\\" st)
(defconst js--syntax-propertize-regexp-regexp
;; Start of regexp.
(0+ (or
;; Match characters outside of a character class.
(not (any ?\[ ?/ ?\\))
;; Match backslash quoted characters.
(and "\\" not-newline)
;; Match character class.
(0+ (or
(not (any ?\] ?\\))
(and "\\" not-newline)))
(group "/"))
"Regular expression matching a JavaScript regexp literal.")
(defun js-syntax-propertize-regexp (end)
(let ((ppss (syntax-ppss)))
(when (eq (nth 3 ppss) ?/)
;; A /.../ regexp.
(when (re-search-forward "\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*/"
end 'move)
(if (nth 1 (with-syntax-table
(let ((parse-sexp-lookup-properties nil))
(parse-partial-sexp (nth 8 ppss) (point)))))
;; A / within a character class is not the end of a regexp.
(put-text-property (1- (point)) (point)
'syntax-table (string-to-syntax "\"/"))
(goto-char (nth 8 ppss))
(when (and (looking-at js--syntax-propertize-regexp-regexp)
;; Don't touch text after END.
(<= (match-end 1) end))
(put-text-property (match-beginning 1) (match-end 1)
'syntax-table (string-to-syntax "\"/"))
(goto-char (match-end 0))))))
(defun js-syntax-propertize (start end)
;; JavaScript allows immediate regular expression objects, written /.../.
......@@ -1010,7 +1010,7 @@ if the header needs to be version controlled.
The following keywords for template generation are supported:
<filename> : replaced by the name of the buffer
<author> : replaced by the user name and email address
(`user-full-name',`mail-host-address', `user-mail-address')
(`user-full-name', `user-mail-address')
<authorfull> : replaced by the user full name (`user-full-name')
<login> : replaced by user login name (`user-login-name')
<company> : 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)
......@@ -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)
: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)
(when query-replace-from-to-separator
(propertize "\0"
'display query-replace-from-to-separator
(if (char-displayable-p
(string-to-char (replace-regexp-in-string
" " "" query-replace-from-to-separator)))
" -> ")
'face 'minibuffer-prompt)
'separator t)))
......@@ -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
(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)))
(format "%s (default %s -> %s): " prompt
(query-replace-descr (caar query-replace-defaults))
(query-replace-descr (cdar query-replace-defaults))))
(t (format "%s: " prompt))))
;; 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)
prompt nil nil nil nil
(car (if regexp-flag regexp-search-ring search-ring)) t)))))
prompt nil nil nil nil (car search-ring) t)))))
(if (and (zerop (length from)) query-replace-defaults)
(cons (caar query-replace-defaults)
......@@ -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
......@@ -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))
......@@ -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)
......@@ -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."
......@@ -1190,8 +1190,10 @@ to look up will be substituted there."
"A helper for `css-lookup-symbol' that finds the symbol at point.
Returns the symbol, a string, or nil if none found."
;; Skip backward over a word first.
(skip-chars-backward "-[:alnum:] \t")
;; Skip any whitespace between the word and point.
(skip-chars-backward "- \t")
;; Skip backward over a word.
(skip-chars-backward "-[:alnum:]")
;; Now skip ":" or "@" to see if it's a pseudo-element or at-id.
(skip-chars-backward "@:")
(if (looking-at css--mdn-symbol-regexp)
......@@ -569,7 +569,7 @@ and all `time-stamp-format' compatibility."
((eq cur-char ?L) ;(undocumented alt user full name)
((eq cur-char ?h) ;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)
(provide 'time-stamp)
;;; time-stamp.el ends here
......@@ -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
(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
(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)
......@@ -23,6 +23,7 @@
(require 'ert)
(require 'js)
(require 'syntax)
(ert-deftest js-mode-fill-bug-19399 ()
......@@ -99,6 +100,22 @@ if (!/[ (:,='\"]/.test(value)) {
(should (looking-at " \\* test"))))
(ert-deftest js-mode-regexp-syntax-bug-25529 ()
(dolist (regexp-contents '("[^[]"
;; A comment with the regexp on the next
;; line.
(insert "let x = /" regexp-contents "/;\n")
(save-excursion (insert "something();\n"))
;; The failure mode was that the regexp literal was not
;; recognized, causing the next line to be given string syntax;
;; but check for comment syntax as well to prevent an
;; implementation not recognizing the comment example.
(should-not (syntax-ppss-context (syntax-ppss))))))
(provide 'js-tests)
;;; js-tests.el ends here
......@@ -226,7 +226,8 @@
("a:v" "isited" ":visited")
("border-" "color: red" "border-color")
("border-color: red" ";" "border-color")
("border-color: red; color: green" ";" "color")))
("border-color: red; color: green" ";" "color")
(" border-collapse " ": collapse;" "border-collapse")))
(insert (nth 0 item))
......@@ -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