commit 8f544c610445e763c4fca4a2d6773a099385a3a6 (HEAD, refs/remotes/origin/master) Author: Lars Ingebrigtsen Date: Wed May 15 09:45:08 2019 +0200 Describe error data in url-retrieve better * lisp/url/url.el (url-retrieve): Describe the error data more in depth (bug#25735). diff --git a/lisp/url/url.el b/lisp/url/url.el index ed0947795b..5242d42f04 100644 --- a/lisp/url/url.el +++ b/lisp/url/url.el @@ -136,9 +136,11 @@ STATUS is a plist representing what happened during the request, with most recent events first, or an empty list if no events have occurred. Each pair is one of: -\(:redirect REDIRECTED-TO) - the request was redirected to this URL -\(:error (ERROR-SYMBOL . DATA)) - an error occurred. The error can be -signaled with (signal ERROR-SYMBOL DATA). +\(:redirect REDIRECTED-TO) - the request was redirected to this URL. + +\(:error (error type . DATA)) - an error occurred. TYPE is a +symbol that says something about where the error occurred, and +DATA is a list (possibly nil) that describes the error further. Return the buffer URL will load into, or nil if the process has already completed (i.e. URL was a mailto URL or similar; in this case commit ceed3d7557a93ae1a231c65c08ac787a10b8bad7 Author: Lars Ingebrigtsen Date: Wed May 15 07:34:35 2019 +0200 Don't have url-basic-auth bug out when called with an URL string * lisp/url/url-auth.el (url-basic-auth): Pass the parsed URL object to the prompting function instead of the parameter that's possibly a string (bug#26708). Passing url-basic-auth with a string parameter would fail if passed a non-parsed URL. diff --git a/lisp/url/url-auth.el b/lisp/url/url-auth.el index f644787cc6..beed7c6cb6 100644 --- a/lisp/url/url-auth.el +++ b/lisp/url/url-auth.el @@ -86,7 +86,7 @@ instead of the filename inheritance method." ((and prompt (not byserv)) (setq user (or (url-do-auth-source-search server type :user) - (read-string (url-auth-user-prompt url realm) + (read-string (url-auth-user-prompt href realm) (or user (user-real-login-name)))) pass (or (url-do-auth-source-search server type :secret) @@ -115,7 +115,7 @@ instead of the filename inheritance method." (progn (setq user (or (url-do-auth-source-search server type :user) - (read-string (url-auth-user-prompt url realm) + (read-string (url-auth-user-prompt href realm) (user-real-login-name))) pass (or (url-do-auth-source-search server type :secret) commit 4f1df40db36b221e7842bd75d6281922dcb268ee Author: Lars Ingebrigtsen Date: Wed May 15 07:12:26 2019 +0200 Fix obscure HTTP chunked parsing problem * lisp/url/url-http.el (url-http-chunked-encoding-after-change-function): Ensure that we parse the entire initial chunked header as the length (bug#35658). diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 03b863b69a..48e29987a5 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -1084,6 +1084,12 @@ the end of the document." ;; need to spin some more. (url-http-debug "Did not see start of chunk @ %d!" (point)) (setq read-next-chunk nil)) + ;; The data we got may have started in the middle of the + ;; initial chunk header, so move back to the start of the + ;; line and re-compute. + (when (= url-http-chunked-counter 0) + (beginning-of-line) + (looking-at regexp)) (add-text-properties (match-beginning 0) (match-end 0) (list 'start-open t 'end-open t commit 15bd081ce608c9ebdd379dccc728618664d458a6 Author: Lars Ingebrigtsen Date: Wed May 15 06:59:12 2019 +0200 Indent url-http-chunked-encoding-after-change-function diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 662b6664b1..03b863b69a 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -1080,7 +1080,7 @@ the end of the document." (if no-initial-crlf (skip-chars-forward "\r\n")) (if (not (looking-at regexp)) (progn - ;; Must not have received the entirety of the chunk header, + ;; Must not have received the entirety of the chunk header, ;; need to spin some more. (url-http-debug "Did not see start of chunk @ %d!" (point)) (setq read-next-chunk nil)) @@ -1099,8 +1099,7 @@ the end of the document." (or url-http-chunked-start (make-marker)) (match-end 0))) -; (if (not url-http-debug) - (delete-region (match-beginning 0) (match-end 0));) + (delete-region (match-beginning 0) (match-end 0)) (url-http-debug "Saw start of chunk %d (length=%d, start=%d" url-http-chunked-counter url-http-chunked-length (marker-position url-http-chunked-start)) commit 4fa6029f7ee30aa3316d6d73db61462730042908 Author: Thomas Fitzsimmons Date: Wed May 15 06:14:21 2019 +0200 Fix url-auth prompts when realm is empty * lisp/url/url-auth.el (url-get-authentication): When realm is empty, use the entire URL in the prompt (bug#35688). diff --git a/lisp/url/url-auth.el b/lisp/url/url-auth.el index 0746cfd96c..f644787cc6 100644 --- a/lisp/url/url-auth.el +++ b/lisp/url/url-auth.el @@ -478,6 +478,8 @@ PROMPT is boolean - specifies whether to ask the user for a username/password if one cannot be found in the cache" (if (not realm) (setq realm (cdr-safe (assoc "realm" args)))) + (if (equal realm "") + (setq realm nil)) (if (stringp url) (setq url (url-generic-parse-url url))) (if (or (null type) (eq type 'any)) commit e3fbe04cbcfecbf3c8b6c8686a2612dbd4b6386a Author: Lars Ingebrigtsen Date: Wed May 15 02:53:56 2019 +0200 Make image scaling work without imagemagick support in eww * lisp/net/shr.el (shr-rescale-image): Emacs has native image scaling now, so images can be rescaled without imagemagick support. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 3ab5116597..3ff0c24778 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1101,39 +1101,36 @@ WIDTH and HEIGHT are the sizes given in the HTML data, if any. The size of the displayed image will not exceed MAX-WIDTH/MAX-HEIGHT. If not given, use the current window width/height instead." - (if (or (not (fboundp 'imagemagick-types)) - (not (get-buffer-window (current-buffer)))) - (create-image data nil t :ascent 100) - (let* ((edges (window-inside-pixel-edges - (get-buffer-window (current-buffer)))) - (max-width (truncate (* shr-max-image-proportion - (or max-width - (- (nth 2 edges) (nth 0 edges)))))) - (max-height (truncate (* shr-max-image-proportion - (or max-height - (- (nth 3 edges) (nth 1 edges)))))) - (scaling (image-compute-scaling-factor image-scaling-factor))) - (when (or (and width - (> width max-width)) - (and height - (> height max-height))) - (setq width nil - height nil)) - (if (and width height - (< (* width scaling) max-width) - (< (* height scaling) max-height)) - (create-image - data 'imagemagick t - :ascent 100 - :width width - :height height - :format content-type) + (let* ((edges (window-inside-pixel-edges + (get-buffer-window (current-buffer)))) + (max-width (truncate (* shr-max-image-proportion + (or max-width + (- (nth 2 edges) (nth 0 edges)))))) + (max-height (truncate (* shr-max-image-proportion + (or max-height + (- (nth 3 edges) (nth 1 edges)))))) + (scaling (image-compute-scaling-factor image-scaling-factor))) + (when (or (and width + (> width max-width)) + (and height + (> height max-height))) + (setq width nil + height nil)) + (if (and width height + (< (* width scaling) max-width) + (< (* height scaling) max-height)) (create-image - data 'imagemagick t + data nil t :ascent 100 - :max-width max-width - :max-height max-height - :format content-type))))) + :width width + :height height + :format content-type) + (create-image + data nil t + :ascent 100 + :max-width max-width + :max-height max-height + :format content-type)))) ;; url-cache-extract autoloads url-cache. (declare-function url-cache-create-filename "url-cache" (url)) commit 4b2c9f638affcbbed171e3381ee523135ee3c31a Merge: 5fe9375a51 cf5457764c Author: Glenn Morris Date: Tue May 14 17:18:19 2019 -0700 ; Merge from origin/emacs-26 The following commits were skipped: cf54577 (origin/emacs-26) Backport: fix broken build on m68k 202ff53 Handle GNUTLS_E_AGAIN in emacs_gnutls_read (Bug#34341) commit 5fe9375a5164960c3ecb65a7ef6d742069b8a7d7 Merge: 0f63e17663 02bee7860f Author: Glenn Morris Date: Tue May 14 17:18:18 2019 -0700 Merge from origin/emacs-26 02bee78 Let dir locals for more specific modes override those from less b1235f9 Improve documentation of Hexl mode 32d1813 Fix description of (move-to-column t) when column is ... 0397b7c ; Fix smtpmail-stream-type docstring 7dab3ee Recognize single quote attribute values in nxml and sgml (Bug... e4cde42 Disable extra display of in nxml-mode (Bug#32897) ca14dd1 Fix nxml-get-inside (Bug#32003) e7ab351 Fix positioning client buffer as instructed by emacsclient # Conflicts: # lisp/files.el # lisp/textmodes/sgml-mode.el commit 0f63e17663f99742425c9ec4f282f5e7e3194b1b Merge: c11c990356 916510b6d9 Author: Glenn Morris Date: Tue May 14 17:10:28 2019 -0700 ; Merge from origin/emacs-26 The following commit was skipped: 916510b * etc/package-keyring.gpg: Add the 2019 key (backport) commit c11c9903565c3fcab98ce715c5520ae1e349861f Author: Juri Linkov Date: Tue May 14 23:40:31 2019 +0300 * lisp/progmodes/project.el (project-read-file-name-function): Fix type. diff --git a/etc/NEWS b/etc/NEWS index f7ee9a9dfe..fc3ca1ea92 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -518,8 +518,11 @@ The mode is automatically enabled in files that start with the 'function' keyword. ** project.el + *** New commands 'project-search' and 'project-query-replace-regexp'. +*** New customizable variable 'project-read-file-name-function'. + ** Etags +++ @@ -1987,8 +1990,6 @@ returns a regexp that never matches anything, which is an identity for this operation. Previously, the empty string was returned in this case. -** New variable project-read-file-name-function. - * Changes in Emacs 27.1 on Non-Free Operating Systems diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index ddb4f3354c..eab508af3a 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -467,11 +467,12 @@ recognized." (defcustom project-read-file-name-function #'project--read-file-cpd-relative "Function to call to read a file name from a list. For the arguments list, see `project--read-file-cpd-relative'." - :type '(repeat (choice (const :tag "Read with completion from relative names" - project--read-file-cpd-relative) - (const :tag "Read with completion from absolute names" - project--read-file-absolute) - (function :tag "custom function" nil)))) + :type '(choice (const :tag "Read with completion from relative names" + project--read-file-cpd-relative) + (const :tag "Read with completion from absolute names" + project--read-file-absolute) + (function :tag "Custom function" nil)) + :version "27.1") (defun project--read-file-cpd-relative (prompt all-files &optional predicate commit cf5457764c1288ee34e01d82deb596950fc9f885 (refs/remotes/origin/emacs-26) Author: Paul Eggert Date: Mon May 13 12:43:13 2019 -0700 Backport: fix broken build on m68k The GCC + valgrind fix caused the m68k build to fail (Bug#35711). Simplify string allocation a bit to make similar problems less likely in the future. * src/alloc.c (sdata, SDATA_NBYTES, SDATA_DATA) [GC_CHECK_STRING_BYTES]: Use the same implementation as with !GC_CHECK_STRING_BYTES, as the special case is no longer needed. (SDATA_ALIGN): New constant. (SDATA_SIZE): Remove this macro, replacing with ... (sdata_size): ... this new function. All uses changed. Properly account for sizes and alignments even in the m68k case, and even if GC_CHECK_STRING_BYTES is not defined. diff --git a/src/alloc.c b/src/alloc.c index 6fd78188a0..6aeac140ca 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1607,9 +1607,7 @@ mark_interval (INTERVAL i, void *dummy) #define LARGE_STRING_BYTES 1024 -/* The SDATA typedef is a struct or union describing string memory - sub-allocated from an sblock. This is where the contents of Lisp - strings are stored. */ +/* The layout of a nonnull string. */ struct sdata { @@ -1628,13 +1626,8 @@ struct sdata unsigned char data[FLEXIBLE_ARRAY_MEMBER]; }; -#ifdef GC_CHECK_STRING_BYTES - -typedef struct sdata sdata; -#define SDATA_NBYTES(S) (S)->nbytes -#define SDATA_DATA(S) (S)->data - -#else +/* A union describing string memory sub-allocated from an sblock. + This is where the contents of Lisp strings are stored. */ typedef union { @@ -1662,8 +1655,6 @@ typedef union #define SDATA_NBYTES(S) (S)->n.nbytes #define SDATA_DATA(S) ((struct sdata *) (S))->data -#endif /* not GC_CHECK_STRING_BYTES */ - enum { SDATA_DATA_OFFSET = offsetof (struct sdata, data) }; /* Structure describing a block of memory which is sub-allocated to @@ -1754,31 +1745,20 @@ static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] = #define GC_STRING_OVERRUN_COOKIE_SIZE 0 #endif -/* Value is the size of an sdata structure large enough to hold NBYTES - bytes of string data. The value returned includes a terminating - NUL byte, the size of the sdata structure, and padding. */ - -#ifdef GC_CHECK_STRING_BYTES - -#define SDATA_SIZE(NBYTES) FLEXSIZEOF (struct sdata, data, (NBYTES) + 1) - -#else /* not GC_CHECK_STRING_BYTES */ - -/* The 'max' reserves space for the nbytes union member even when NBYTES + 1 is - less than the size of that member. The 'max' is not needed when - SDATA_DATA_OFFSET is a multiple of FLEXALIGNOF (struct sdata), - because then the alignment code reserves enough space. */ - -#define SDATA_SIZE(NBYTES) \ - ((SDATA_DATA_OFFSET \ - + (SDATA_DATA_OFFSET % FLEXALIGNOF (struct sdata) == 0 \ - ? NBYTES \ - : max (NBYTES, FLEXALIGNOF (struct sdata) - 1)) \ - + 1 \ - + FLEXALIGNOF (struct sdata) - 1) \ - & ~(FLEXALIGNOF (struct sdata) - 1)) +/* Return the size of an sdata structure large enough to hold N bytes + of string data. This counts the sdata structure, the N bytes, a + terminating NUL byte, and alignment padding. */ -#endif /* not GC_CHECK_STRING_BYTES */ +static ptrdiff_t +sdata_size (ptrdiff_t n) +{ + /* Reserve space for the nbytes union member even when N + 1 is less + than the size of that member. */ + ptrdiff_t unaligned_size = max (SDATA_DATA_OFFSET + n + 1, + sizeof (sdata)); + int sdata_align = max (FLEXALIGNOF (struct sdata), alignof (sdata)); + return (unaligned_size + sdata_align - 1) & ~(sdata_align - 1); +} /* Extra bytes to allocate for each string. */ @@ -1831,21 +1811,14 @@ string_bytes (struct Lisp_String *s) static void check_sblock (struct sblock *b) { - sdata *from, *end, *from_end; - - end = b->next_free; + sdata *end = b->next_free; - for (from = b->data; from < end; from = from_end) + for (sdata *from = b->data; from < end; ) { - /* Compute the next FROM here because copying below may - overwrite data we need to compute it. */ - ptrdiff_t nbytes; - - /* Check that the string size recorded in the string is the - same as the one recorded in the sdata structure. */ - nbytes = SDATA_SIZE (from->string ? string_bytes (from->string) - : SDATA_NBYTES (from)); - from_end = (sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); + ptrdiff_t nbytes = sdata_size (from->string + ? string_bytes (from->string) + : SDATA_NBYTES (from)); + from = (sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); } } @@ -1977,14 +1950,14 @@ allocate_string_data (struct Lisp_String *s, { sdata *data, *old_data; struct sblock *b; - ptrdiff_t needed, old_nbytes; + ptrdiff_t old_nbytes; if (STRING_BYTES_MAX < nbytes) string_overflow (); /* Determine the number of bytes needed to store NBYTES bytes of string data. */ - needed = SDATA_SIZE (nbytes); + ptrdiff_t needed = sdata_size (nbytes); if (s->u.s.data) { old_data = SDATA_OF_STRING (s); @@ -2234,7 +2207,7 @@ compact_small_strings (void) nbytes = s ? STRING_BYTES (s) : SDATA_NBYTES (from); eassert (nbytes <= LARGE_STRING_BYTES); - nbytes = SDATA_SIZE (nbytes); + nbytes = sdata_size (nbytes); sdata *from_end = (sdata *) ((char *) from + nbytes + GC_STRING_EXTRA); commit 624a232a8df44f8ca82a2900f88a4c5ef324bf53 Author: Stefan Monnier Date: Tue May 14 14:00:58 2019 -0400 * lisp/savehist.el: Use lexical-binding Remove redundant :group args. (savehist-no-conversion): Remove constant. (savehist-save): Use savehist-coding-system instead since it's no slower. diff --git a/lisp/savehist.el b/lisp/savehist.el index 1eab18ef76..fb3b748339 100644 --- a/lisp/savehist.el +++ b/lisp/savehist.el @@ -1,4 +1,4 @@ -;;; savehist.el --- Save minibuffer history +;;; savehist.el --- Save minibuffer history -*- lexical-binding:t -*- ;; Copyright (C) 1997, 2005-2019 Free Software Foundation, Inc. @@ -62,8 +62,7 @@ "If non-nil, save all recorded minibuffer histories. If you want to save only specific histories, use `savehist-save-hook' to modify the value of `savehist-minibuffer-history-variables'." - :type 'boolean - :group 'savehist) + :type 'boolean) (defcustom savehist-additional-variables () "List of additional variables to save. @@ -77,13 +76,11 @@ non-nil. User options should be saved with the Customize interface. This list is useful for saving automatically updated variables that are not minibuffer histories, such as `compile-command' or `kill-ring'." - :type '(repeat variable) - :group 'savehist) + :type '(repeat variable)) (defcustom savehist-ignored-variables nil ;; '(command-history) "List of additional variables not to save." - :type '(repeat variable) - :group 'savehist) + :type '(repeat variable)) (defcustom savehist-file (locate-user-emacs-file "history" ".emacs-history") @@ -95,8 +92,7 @@ for more details. If you want your minibuffer history shared between Emacs and XEmacs, customize this value and make sure that `savehist-coding-system' is set to a coding system that exists in both emacsen." - :type 'file - :group 'savehist) + :type 'file) (defcustom savehist-file-modes #o600 "Default permissions of the history file. @@ -104,27 +100,23 @@ This is decimal, not octal. The default is 384 (0600 in octal). Set to nil to use the default permissions that Emacs uses, typically mandated by umask. The default is a bit more restrictive to protect the user's privacy." - :type 'integer - :group 'savehist) + :type 'integer) (defcustom savehist-autosave-interval (* 5 60) "The interval between autosaves of minibuffer history. If set to nil, disables timer-based autosaving." :type '(choice (const :tag "Disabled" nil) - (integer :tag "Seconds")) - :group 'savehist) + (integer :tag "Seconds"))) (defcustom savehist-mode-hook nil "Hook called when Savehist mode is turned on." - :type 'hook - :group 'savehist) + :type 'hook) (defcustom savehist-save-hook nil "Hook called by `savehist-save' before saving the variables. You can use this hook to influence choice and content of variables to save." - :type 'hook - :group 'savehist) + :type 'hook) ;; This should be capable of representing characters used by Emacs. ;; We prefer UTF-8 over ISO 2022 because it is well-known outside @@ -150,12 +142,6 @@ The contents of this variable is built while Emacs is running, and saved along with minibuffer history. You can change its value off `savehist-save-hook' to influence which variables are saved.") -(defconst savehist-no-conversion (if (featurep 'xemacs) 'binary 'no-conversion) - "Coding system without any conversion. -This is used for calculating an internal checksum. Should be as fast -as possible, ideally simply exposing the internal representation of -buffer text.") - (defvar savehist-loaded nil "Whether the history has already been loaded. This prevents toggling Savehist mode from destroying existing @@ -223,8 +209,8 @@ histories, which is probably undesirable." Normally invoked by calling `savehist-mode' to set the minor mode. Installs `savehist-autosave' in `kill-emacs-hook' and on a timer. To undo this, call `savehist-uninstall'." - (add-hook 'minibuffer-setup-hook 'savehist-minibuffer-hook) - (add-hook 'kill-emacs-hook 'savehist-autosave) + (add-hook 'minibuffer-setup-hook #'savehist-minibuffer-hook) + (add-hook 'kill-emacs-hook #'savehist-autosave) ;; Install an invocation of savehist-autosave on a timer. This ;; should not cause noticeable delays for users -- savehist-autosave ;; executes in under 5 ms on my system. @@ -233,16 +219,16 @@ To undo this, call `savehist-uninstall'." (setq savehist-timer (if (featurep 'xemacs) (start-itimer - "savehist" 'savehist-autosave savehist-autosave-interval + "savehist" #'savehist-autosave savehist-autosave-interval savehist-autosave-interval) (run-with-timer savehist-autosave-interval - savehist-autosave-interval 'savehist-autosave))))) + savehist-autosave-interval #'savehist-autosave))))) (defun savehist-uninstall () "Undo installing savehist. Normally invoked by calling `savehist-mode' to unset the minor mode." - (remove-hook 'minibuffer-setup-hook 'savehist-minibuffer-hook) - (remove-hook 'kill-emacs-hook 'savehist-autosave) + (remove-hook 'minibuffer-setup-hook #'savehist-minibuffer-hook) + (remove-hook 'kill-emacs-hook #'savehist-autosave) (when savehist-timer (if (featurep 'xemacs) (delete-itimer savehist-timer) @@ -327,7 +313,7 @@ If AUTO-SAVE is non-nil, compare the saved contents to the one last saved, (insert ?\n)))))) ;; If autosaving, avoid writing if nothing has changed since the ;; last write. - (let ((checksum (md5 (current-buffer) nil nil savehist-no-conversion))) + (let ((checksum (md5 (current-buffer) nil nil savehist-coding-system))) (unless (and auto-save (equal checksum savehist-last-checksum)) ;; Set file-precious-flag when saving the buffer because we ;; don't want a half-finished write ruining the entire commit 202ff53da267f9fa15f438e9c38603bbead6e890 Author: Noam Postavsky Date: Mon May 6 19:55:17 2019 -0400 Handle GNUTLS_E_AGAIN in emacs_gnutls_read (Bug#34341) Don't merge to master, this has already been fixed there by 2019-01-15 "Fix unlikely races with GnuTLS, datagrams". * src/gnutls.c (emacs_gnutls_read): Similar to emacs_gnutls_write, when gnutls_record_recv returns GNUTLS_E_AGAIN set errno to EGAIN. diff --git a/src/gnutls.c b/src/gnutls.c index 3c16b6c9c3..b724c3592d 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -753,8 +753,15 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte) /* The peer closed the connection. */ return 0; else if (emacs_gnutls_handle_error (state, rtnval)) - /* non-fatal error */ - return -1; + { + /* If we get GNUTLS_E_AGAIN, then set errno appropriately so that + wait_reading_process_output retries the correct way instead of + erroring out. */ + if (rtnval == GNUTLS_E_AGAIN) + errno = EAGAIN; + /* non-fatal error */ + return -1; + } else { /* a fatal error occurred */ return 0; commit 02bee7860f7e650ef13e00fe1a7f9a362e3eb001 Author: Neil Roberts Date: Fri May 10 12:57:28 2019 +0200 Let dir locals for more specific modes override those from less The list of dir local variables to apply is now sorted by the number of parent modes of the mode used as the key in the association list. That way when the variables are applied in order the variables from more specific modes will override those from less specific modes. If there are directory entries in the list then they are sorted in order of name length. The list of modes for that dir is then recursively sorted with the same mechanism. That way variables tied to a particular subdirectory override those in in a parent directory. Previously the behaviour didn’t seem to be well defined anyway and was dependent on the order they appeared in the file. However this order was changed in version 26.1 and it probably also depended on the number of dir-local files that are merged. Bug#33400 * lisp/files.el (dir-locals-get-sort-score, dir-locals-sort-variables) (dir-locals-read-from-dir): Sort the dir locals so that more precise modes and directory-specific entries have override lesser ones. * doc/emacs/custom.texi (Directory Variables): Document the priority. diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index b07362f3ce..3fd655048b 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -1375,6 +1375,28 @@ be applied in the current directory, not in any subdirectories. Finally, it specifies a different @file{ChangeLog} file name for any file in the @file{src/imported} subdirectory. +If the @file{.dir-locals.el} file contains multiple different values +for a variable using different mode names or directories, the values +will be applied in an order such that the values for more specific +modes take priority over more generic modes. Values specified under a +directory have even more priority. For example: + +@example +((nil . ((fill-column . 40))) + (c-mode . ((fill-column . 50))) + (prog-mode . ((fill-column . 60))) + ("narrow-files" . ((nil . ((fill-column . 20)))))) +@end example + +Files that use @code{c-mode} also match @code{prog-mode} because the +former inherits from the latter. The value used for +@code{fill-column} in C files will however be @code{50} because the +mode name is more specific than @code{prog-mode}. Files using other +modes inheriting from @code{prog-mode} will use @code{60}. Any file +under the directory @file{narrow-files} will use the value @code{20} +even if they use @code{c-mode} because directory entries have priority +over mode entries. + You can specify the variables @code{mode}, @code{eval}, and @code{unibyte} in your @file{.dir-locals.el}, and they have the same meanings as they would have in file local variables. @code{coding} diff --git a/lisp/files.el b/lisp/files.el index d7ed248786..f3b502095d 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -4026,6 +4026,52 @@ This function returns either: ;; No cache entry. locals-dir))) +(defun dir-locals--get-sort-score (node) + "Return a number used for sorting the definitions of dir locals. +NODE is assumed to be a cons cell where the car is either a +string or a symbol representing a mode name. + +If it is a mode then the the depth of the mode (ie, how many +parents that mode has) will be returned. + +If it is a string then the length of the string plus 1000 will be +returned. + +Otherwise it returns -1. + +That way the value can be used to sort the list such that deeper +modes will be after the other modes. This will be followed by +directory entries in order of length. If the entries are all +applied in order then that means the more specific modes will +override the values specified by the earlier modes and directory +variables will override modes." + (let ((key (car node))) + (cond ((null key) -1) + ((symbolp key) + (let ((mode key) + (depth 0)) + (while (setq mode (get mode 'derived-mode-parent)) + (setq depth (1+ depth))) + depth)) + ((stringp key) + (+ 1000 (length key))) + (t -2)))) + +(defun dir-locals--sort-variables (variables) + "Sorts VARIABLES so that applying them in order has the right effect. +The variables are compared by dir-locals--get-sort-score. +Directory entries are then recursively sorted using the same +criteria." + (setq variables (sort variables + (lambda (a b) + (< (dir-locals--get-sort-score a) + (dir-locals--get-sort-score b))))) + (dolist (n variables) + (when (stringp (car n)) + (setcdr n (dir-locals--sort-variables (cdr n))))) + + variables) + (defun dir-locals-read-from-dir (dir) "Load all variables files in DIR and register a new class and instance. DIR is the absolute name of a directory which must contain at @@ -4054,6 +4100,7 @@ Return the new class name, which is a symbol named DIR." (read (current-buffer)))) (end-of-file nil)))) (setq success latest)) + (setq variables (dir-locals--sort-variables variables)) (dir-locals-set-class-variables class-name variables) (dir-locals-set-directory-class dir class-name success) class-name)) commit b1235f9abd0f255ff65e13b18ef3ee4e19278484 Author: Eli Zaretskii Date: Sat May 11 15:00:06 2019 +0300 Improve documentation of Hexl mode * doc/emacs/misc.texi (Editing Binary Files): Clarify "insertion". Improve wording. Add a few Hexl commands. (Bug#35580) diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index fc6b4cf1e7..75cca72190 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -2423,10 +2423,13 @@ automatically back to binary. into hex. This is useful if you visit a file normally and then discover it is a binary file. - Ordinary text characters overwrite in Hexl mode. This is to reduce + Inserting text always overwrites in Hexl mode. This is to reduce the risk of accidentally spoiling the alignment of data in the file. -There are special commands for insertion. Here is a list of the -commands of Hexl mode: +Ordinary text characters insert themselves (i.e., overwrite with +themselves). There are commands for insertion of special characters +by their code. Most cursor motion keys, as well as @kbd{C-x C-s}, are +bound in Hexl mode to commands that produce the same effect. Here is +a list of other important commands special to Hexl mode: @c I don't think individual index entries for these commands are useful--RMS. @table @kbd @@ -2439,6 +2442,12 @@ Insert a byte with a code typed in octal. @item C-M-x Insert a byte with a code typed in hex. +@item C-M-a +Move to the beginning of a 512-byte page. + +@item C-M-e +Move to the end of a 512-byte page. + @item C-x [ Move to the beginning of a 1k-byte page. commit 32d181326a752375ce31796556017b94878d2d2b Author: Alan Mackenzie Date: Thu May 9 16:27:03 2019 +0000 Fix description of (move-to-column t) when column is inside a tab This fixes bug #35647. State that when indent-tabs-mode is non-nil, spaces are inserted before the tab rather than the tab being replaced by spaces. * doc/lispref/text.texi (columns) * src/indent.c (move-to-column): Make the above documentation amendment. diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 73312bb0ca..f3d222b708 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -2245,9 +2245,11 @@ If it is impossible to move to column @var{column} because that is in the middle of a multicolumn character such as a tab, point moves to the end of that character. However, if @var{force} is non-@code{nil}, and @var{column} is in the middle of a tab, then @code{move-to-column} -converts the tab into spaces so that it can move precisely to column -@var{column}. Other multicolumn characters can cause anomalies despite -@var{force}, since there is no way to split them. +either converts the tab into spaces (when @code{indent-tabs-mode} is +@code{nil}), or inserts enough spaces before it (otherwise), so that +point can move precisely to column @var{column}. Other multicolumn +characters can cause anomalies despite @var{force}, since there is no +way to split them. The argument @var{force} also has an effect if the line isn't long enough to reach column @var{column}; if it is @code{t}, that means to diff --git a/src/indent.c b/src/indent.c index 5e3a7e0592..53f998d699 100644 --- a/src/indent.c +++ b/src/indent.c @@ -983,9 +983,10 @@ If specified column is within a character, point goes after that character. If it's past end of line, point goes to end of line. Optional second argument FORCE non-nil means if COLUMN is in the -middle of a tab character, change it to spaces. -In addition, if FORCE is t, and the line is too short to reach -COLUMN, add spaces/tabs to get there. +middle of a tab character, either change it to spaces (when +`indent-tabs-mode' is nil), or insert enough spaces before it to reach +COLUMN (otherwise). In addition, if FORCE is t, and the line is too short +to reach COLUMN, add spaces/tabs to get there. The return value is the current column. */) (Lisp_Object column, Lisp_Object force) commit 0397b7c797b891906bd6613b46a5634aba468fb9 Author: Noam Postavsky Date: Sun May 5 12:27:32 2019 -0400 ; Fix smtpmail-stream-type docstring * lisp/mail/smtpmail.el (smtpmail-stream-type): Remove redundant docstring verbiage. diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index 0043fafb4a..5502e7cfa6 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -101,9 +101,9 @@ don't define this value." (defcustom smtpmail-stream-type nil "Type of SMTP connections to use. -This may be either nil (possibly upgraded to STARTTLS if possible), -or `starttls' (refuse to send if STARTTLS isn't available), or `plain' -\(never use STARTTLS), or `ssl' (to use TLS/SSL)." +This may be either nil (upgrade with STARTTLS if possible), +`starttls' (refuse to send if STARTTLS isn't available), +`plain' (never use STARTTLS), or `ssl' (to use TLS/SSL)." :version "24.1" :group 'smtpmail :type '(choice (const :tag "Possibly upgrade to STARTTLS" nil) commit 7dab3ee7ab54b3c2e7bc24170376054786c01d6f Author: Noam Postavsky Date: Sun Apr 21 22:44:50 2019 -0400 Recognize single quote attribute values in nxml and sgml (Bug#35381) * lisp/textmodes/sgml-mode.el (sgml-specials): Add single quote. (sgml-syntax-propertize-rules): Handle single quote. * test/lisp/nxml/nxml-mode-tests.el (nxml-mode-font-lock-quotes): New test. * test/lisp/textmodes/sgml-mode-tests.el (sgml-delete-tag-bug-8203-should-not-delete-apostrophe): Now passes. diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 50b2077ef4..128e58810e 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -100,24 +100,20 @@ a DOCTYPE or an XML declaration." :group 'sgml :type 'hook) -;; As long as Emacs's syntax can't be complemented with predicates to context -;; sensitively confirm the syntax of characters, we have to live with this -;; kludgy kind of tradeoff. -(defvar sgml-specials '(?\") +;; The official handling of "--" is complicated in SGML, and +;; historically not well supported by browser HTML parsers. +;; Recommendations for writing HTML comments is to use +;; (where ... doesn't contain "--") to avoid the complications +;; altogether (XML goes even further by requiring this in the spec). +;; So there is probably no need to handle it "correctly". +(defvar sgml-specials '(?\" ?\') "List of characters that have a special meaning for SGML mode. This list is used when first loading the `sgml-mode' library. -The supported characters and potential disadvantages are: +The supported characters are ?\\\", ?\\=', and ?-. - ?\\\" Makes \" in text start a string. - ?\\=' Makes \\=' in text start a string. - ?- Makes -- in text start a comment. - -When only one of ?\\\" or ?\\=' are included, \"\\='\" or \\='\"\\=', as can be found in -DTDs, start a string. To partially avoid this problem this also makes these -self insert as named entities depending on `sgml-quick-keys'. - -Including ?- has the problem of affecting dashes that have nothing to do -with comments, so we normally turn it off.") +Including ?- makes double dashes into comment delimiters, but +they are really only supposed to delimit comments within DTD +definitions. So we normally turn it off.") (defvar sgml-quick-keys nil "Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil. @@ -351,12 +347,12 @@ Any terminating `>' or `/' is not matched.") ("--[ \t\n]*\\(>\\)" (1 "> b")) ("\\(<\\)[?!]" (1 (prog1 "|>" (sgml-syntax-propertize-inside end)))) - ;; Double quotes outside of tags should not introduce strings. + ;; Quotes outside of tags should not introduce strings. ;; Be careful to call `syntax-ppss' on a position before the one we're ;; going to change, so as not to need to flush the data we just computed. - ("\"" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) - (goto-char (match-end 0))) - (string-to-syntax "."))))))) + ("[\"']" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) + (goto-char (match-end 0))) + (string-to-syntax "."))))))) (defun sgml-syntax-propertize (start end) "Syntactic keywords for `sgml-mode'." diff --git a/test/lisp/nxml/nxml-mode-tests.el b/test/lisp/nxml/nxml-mode-tests.el index 57a731ad18..92744be619 100644 --- a/test/lisp/nxml/nxml-mode-tests.el +++ b/test/lisp/nxml/nxml-mode-tests.el @@ -58,5 +58,25 @@ (nxml-balanced-close-start-tag-inline) (should (equal (buffer-string) "")))) +(ert-deftest nxml-mode-font-lock-quotes () + (with-temp-buffer + (nxml-mode) + (insert "\"dquote text\"'squote text'") + (font-lock-ensure) + (let ((squote-txt-pos (search-backward "squote text")) + (dquote-txt-pos (search-backward "dquote text")) + (squote-att-pos (search-backward "squote attr")) + (dquote-att-pos (search-backward "dquote attr"))) + ;; Just make sure that each quote uses the same face for quoted + ;; attribute values, and a different face for quoted text + ;; outside tags. Don't test `font-lock-string-face' vs + ;; `nxml-attribute-value' here. + (should (equal (get-text-property squote-att-pos 'face) + (get-text-property dquote-att-pos 'face))) + (should (equal (get-text-property squote-txt-pos 'face) + (get-text-property dquote-txt-pos 'face))) + (should-not (equal (get-text-property squote-txt-pos 'face) + (get-text-property dquote-att-pos 'face)))))) + (provide 'nxml-mode-tests) ;;; nxml-mode-tests.el ends here diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el index 20b5e27ff5..7318a667b3 100644 --- a/test/lisp/textmodes/sgml-mode-tests.el +++ b/test/lisp/textmodes/sgml-mode-tests.el @@ -125,7 +125,6 @@ The point is set to the beginning of the buffer." (should (string= content (buffer-string)))))) (ert-deftest sgml-delete-tag-bug-8203-should-not-delete-apostrophe () - :expected-result :failed (sgml-with-content "Winter is comin'" (sgml-delete-tag 1) commit e4cde42657f8f91f795e6b7041dc50b896dc468d Author: Noam Postavsky Date: Fri Apr 19 13:28:00 2019 -0400 Disable extra display of in nxml-mode (Bug#32897) * lisp/nxml/nxml-mode.el (nxml-char-ref-display-extra): Don't put display for the newline, it makes the indentation look wrong. diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index f17f5843b8..ab035b927e 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el @@ -2378,7 +2378,9 @@ With a prefix argument, inserts the character directly." (put 'nxml-char-ref 'evaporate t) (defun nxml-char-ref-display-extra (start end n) - (when nxml-char-ref-extra-display + (when (and ;; Displaying literal newline is unhelpful. + (not (eql n ?\n)) + nxml-char-ref-extra-display) (let ((name (or (get-char-code-property n 'name) (get-char-code-property n 'old-name))) (glyph-string (and nxml-char-ref-display-glyph-flag commit ca14dd1d4628094dd33d5d94694dcf5f29e843b8 Author: Noam Postavsky Date: Thu Apr 18 23:36:04 2019 -0400 Fix nxml-get-inside (Bug#32003) The change from 2016-01-16 "lisp/nxml: Use syntax-tables for comments" made nxml-get-inside return non-nil for any string or comment, including attribute strings. This caused incorrect and therefore indentation. * lisp/nxml/nxml-rap.el: Update commentary to reflect changes to nxml-mode parsing. (nxml-get-inside): Only return non-nil when inside comments and generic strings, not normal quote-delimited strings. * test/lisp/nxml/nxml-mode-tests.el: New tests. diff --git a/lisp/nxml/nxml-rap.el b/lisp/nxml/nxml-rap.el index 2bd758be3a..21dbaded25 100644 --- a/lisp/nxml/nxml-rap.el +++ b/lisp/nxml/nxml-rap.el @@ -35,35 +35,25 @@ ;; ;; Our strategy is to keep track of just the problematic things. ;; Specifically, we keep track of all comments, CDATA sections and -;; processing instructions in the instance. We do this by marking all -;; except the first character of these with a non-nil nxml-inside text -;; property. The value of the nxml-inside property is comment, -;; cdata-section or processing-instruction. The first character does -;; not have the nxml-inside property so we can find the beginning of -;; the construct by looking for a change in a text property value -;; (Emacs provides primitives for this). We use text properties -;; rather than overlays, since the implementation of overlays doesn't -;; look like it scales to large numbers of overlays in a buffer. -;; -;; We don't in fact track all these constructs, but only track them in -;; some initial part of the instance. +;; processing instructions in the instance. We do this by marking +;; the first character of these with the generic string syntax by setting +;; a 'syntax-table' text property in `sgml-syntax-propertize'. ;; ;; Thus to parse some random point in the file we first ensure that we -;; have scanned up to that point. Then we search backwards for a -;; <. Then we check whether the < has an nxml-inside property. If it -;; does we go backwards to first character that does not have an -;; nxml-inside property (this character must be a <). Then we start -;; parsing forward from the < we have found. +;; have scanned up to that point. Then we search backwards for a <. +;; Then we check whether the < has the generic string syntax. If it +;; does we go backwards to first character of the generic string (this +;; character must be a <). Then we start parsing forward from the < +;; we have found. ;; ;; The prolog has to be parsed specially, so we also keep track of the ;; end of the prolog in `nxml-prolog-end'. The prolog is reparsed on ;; every change to the prolog. This won't work well if people try to ;; edit huge internal subsets. Hopefully that will be rare. ;; -;; We keep track of the changes by adding to the buffer's -;; after-change-functions hook. Scanning is also done as a -;; prerequisite to fontification by adding to fontification-functions -;; (in the same way as jit-lock). This means that scanning for these +;; We rely on the `syntax-propertize-function' machinery to keep track +;; of the changes in the buffer. Fontification also relies on correct +;; `syntax-table' properties. This means that scanning for these ;; constructs had better be quick. Fortunately it is. Firstly, the ;; typical proportion of comments, CDATA sections and processing ;; instructions is small relative to other things. Secondly, to scan @@ -79,7 +69,15 @@ "Integer giving position following end of the prolog.") (defsubst nxml-get-inside (pos) - (save-excursion (nth 8 (syntax-ppss pos)))) + "Return non-nil if inside comment, CDATA, or PI." + (let ((ppss (save-excursion (syntax-ppss pos)))) + (or + ;; Inside comment. + (nth 4 ppss) + ;; Inside "generic" string which is used for CDATA, and PI. + ;; "Normal" double and single quoted strings are used for + ;; attribute values. + (eq t (nth 3 ppss))))) (defun nxml-inside-end (pos) "Return the end of the inside region containing POS. diff --git a/test/lisp/nxml/nxml-mode-tests.el b/test/lisp/nxml/nxml-mode-tests.el new file mode 100644 index 0000000000..57a731ad18 --- /dev/null +++ b/test/lisp/nxml/nxml-mode-tests.el @@ -0,0 +1,62 @@ +;;; nxml-mode-tests.el --- Test NXML Mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) +(require 'nxml-mode) + +(defun nxml-mode-tests-correctly-indented-string (str) + (with-temp-buffer + (nxml-mode) + (insert str) + (indent-region (point-min) (point-max)) + (equal (buffer-string) str))) + +(ert-deftest nxml-indent-line-after-attribute () + (should (nxml-mode-tests-correctly-indented-string " + + + ... + + +")) + (should (nxml-mode-tests-correctly-indented-string "\ + + + + + + +"))) + +(ert-deftest nxml-balanced-close-start-tag-inline () + (with-temp-buffer + (nxml-mode) + (insert "") + (search-backward "") + (nxml-balanced-close-start-tag-inline) + (should (equal (buffer-string) "")))) + +(provide 'nxml-mode-tests) +;;; nxml-mode-tests.el ends here commit e7ab351caa884755c032fd9544ba67a3c953144f Author: Eli Zaretskii Date: Wed May 8 20:34:09 2019 +0300 Fix positioning client buffer as instructed by emacsclient * lisp/server.el (server-switch-buffer): Let-bind switch-to-buffer-preserve-window-point to nil when switching to the client buffer, when the client requested a specific position. (Bug#35602) diff --git a/lisp/server.el b/lisp/server.el index a39b1cb46d..42329e853b 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1621,7 +1621,14 @@ be a cons cell (LINENUMBER . COLUMNNUMBER)." (frame-terminal)))) 'nomini 'visible (selected-window)))) (condition-case nil - (switch-to-buffer next-buffer) + ;; If the client specified a new buffer position, + ;; treat that as an explicit point-move command, and + ;; override switch-to-buffer-preserve-window-point. + (let ((switch-to-buffer-preserve-window-point + (if filepos + nil + switch-to-buffer-preserve-window-point))) + (switch-to-buffer next-buffer)) ;; After all the above, we might still have ended up with ;; a minibuffer/dedicated-window (if there's no other). (error (pop-to-buffer next-buffer))))))) commit 916510b6d919a333d1dac528a9d051aa6d857ccc Author: Stefan Monnier Date: Wed May 8 13:19:36 2019 -0400 * etc/package-keyring.gpg: Add the 2019 key (backport) diff --git a/etc/package-keyring.gpg b/etc/package-keyring.gpg index e76e68522f..490dee41a9 100644 Binary files a/etc/package-keyring.gpg and b/etc/package-keyring.gpg differ