diff options
| author | Glenn Morris | 2019-05-14 17:18:18 -0700 |
|---|---|---|
| committer | Glenn Morris | 2019-05-14 17:18:18 -0700 |
| commit | 5fe9375a5164960c3ecb65a7ef6d742069b8a7d7 (patch) | |
| tree | 315715009d9fe5af40be38cb0dfccecfaf4c5528 | |
| parent | 0f63e17663f99742425c9ec4f282f5e7e3194b1b (diff) | |
| parent | 02bee7860f7e650ef13e00fe1a7f9a362e3eb001 (diff) | |
| download | emacs-5fe9375a5164960c3ecb65a7ef6d742069b8a7d7.tar.gz emacs-5fe9375a5164960c3ecb65a7ef6d742069b8a7d7.zip | |
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 <n> t) when column <n> 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
| -rw-r--r-- | doc/emacs/custom.texi | 22 | ||||
| -rw-r--r-- | doc/emacs/misc.texi | 15 | ||||
| -rw-r--r-- | doc/lispref/text.texi | 8 | ||||
| -rw-r--r-- | lisp/files.el | 47 | ||||
| -rw-r--r-- | lisp/mail/smtpmail.el | 6 | ||||
| -rw-r--r-- | lisp/nxml/nxml-mode.el | 4 | ||||
| -rw-r--r-- | lisp/nxml/nxml-rap.el | 42 | ||||
| -rw-r--r-- | lisp/server.el | 9 | ||||
| -rw-r--r-- | lisp/textmodes/sgml-mode.el | 47 | ||||
| -rw-r--r-- | src/indent.c | 7 | ||||
| -rw-r--r-- | test/lisp/nxml/nxml-mode-tests.el | 82 | ||||
| -rw-r--r-- | test/lisp/textmodes/sgml-mode-tests.el | 1 |
12 files changed, 223 insertions, 67 deletions
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 22e352ef9f9..8a8ac5d0464 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi | |||
| @@ -1377,6 +1377,28 @@ be applied in the current directory, not in any subdirectories. | |||
| 1377 | Finally, it specifies a different @file{ChangeLog} file name for any | 1377 | Finally, it specifies a different @file{ChangeLog} file name for any |
| 1378 | file in the @file{src/imported} subdirectory. | 1378 | file in the @file{src/imported} subdirectory. |
| 1379 | 1379 | ||
| 1380 | If the @file{.dir-locals.el} file contains multiple different values | ||
| 1381 | for a variable using different mode names or directories, the values | ||
| 1382 | will be applied in an order such that the values for more specific | ||
| 1383 | modes take priority over more generic modes. Values specified under a | ||
| 1384 | directory have even more priority. For example: | ||
| 1385 | |||
| 1386 | @example | ||
| 1387 | ((nil . ((fill-column . 40))) | ||
| 1388 | (c-mode . ((fill-column . 50))) | ||
| 1389 | (prog-mode . ((fill-column . 60))) | ||
| 1390 | ("narrow-files" . ((nil . ((fill-column . 20)))))) | ||
| 1391 | @end example | ||
| 1392 | |||
| 1393 | Files that use @code{c-mode} also match @code{prog-mode} because the | ||
| 1394 | former inherits from the latter. The value used for | ||
| 1395 | @code{fill-column} in C files will however be @code{50} because the | ||
| 1396 | mode name is more specific than @code{prog-mode}. Files using other | ||
| 1397 | modes inheriting from @code{prog-mode} will use @code{60}. Any file | ||
| 1398 | under the directory @file{narrow-files} will use the value @code{20} | ||
| 1399 | even if they use @code{c-mode} because directory entries have priority | ||
| 1400 | over mode entries. | ||
| 1401 | |||
| 1380 | You can specify the variables @code{mode}, @code{eval}, and | 1402 | You can specify the variables @code{mode}, @code{eval}, and |
| 1381 | @code{unibyte} in your @file{.dir-locals.el}, and they have the same | 1403 | @code{unibyte} in your @file{.dir-locals.el}, and they have the same |
| 1382 | meanings as they would have in file local variables. @code{coding} | 1404 | meanings as they would have in file local variables. @code{coding} |
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 8bb603f49fa..cfc50d33b5f 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi | |||
| @@ -2485,10 +2485,13 @@ automatically back to binary. | |||
| 2485 | into hex. This is useful if you visit a file normally and then discover | 2485 | into hex. This is useful if you visit a file normally and then discover |
| 2486 | it is a binary file. | 2486 | it is a binary file. |
| 2487 | 2487 | ||
| 2488 | Ordinary text characters overwrite in Hexl mode. This is to reduce | 2488 | Inserting text always overwrites in Hexl mode. This is to reduce |
| 2489 | the risk of accidentally spoiling the alignment of data in the file. | 2489 | the risk of accidentally spoiling the alignment of data in the file. |
| 2490 | There are special commands for insertion. Here is a list of the | 2490 | Ordinary text characters insert themselves (i.e., overwrite with |
| 2491 | commands of Hexl mode: | 2491 | themselves). There are commands for insertion of special characters |
| 2492 | by their code. Most cursor motion keys, as well as @kbd{C-x C-s}, are | ||
| 2493 | bound in Hexl mode to commands that produce the same effect. Here is | ||
| 2494 | a list of other important commands special to Hexl mode: | ||
| 2492 | 2495 | ||
| 2493 | @c I don't think individual index entries for these commands are useful--RMS. | 2496 | @c I don't think individual index entries for these commands are useful--RMS. |
| 2494 | @table @kbd | 2497 | @table @kbd |
| @@ -2501,6 +2504,12 @@ Insert a byte with a code typed in octal. | |||
| 2501 | @item C-M-x | 2504 | @item C-M-x |
| 2502 | Insert a byte with a code typed in hex. | 2505 | Insert a byte with a code typed in hex. |
| 2503 | 2506 | ||
| 2507 | @item C-M-a | ||
| 2508 | Move to the beginning of a 512-byte page. | ||
| 2509 | |||
| 2510 | @item C-M-e | ||
| 2511 | Move to the end of a 512-byte page. | ||
| 2512 | |||
| 2504 | @item C-x [ | 2513 | @item C-x [ |
| 2505 | Move to the beginning of a 1k-byte page. | 2514 | Move to the beginning of a 1k-byte page. |
| 2506 | 2515 | ||
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 500df1f8f0d..278bc3c2680 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi | |||
| @@ -2252,9 +2252,11 @@ If it is impossible to move to column @var{column} because that is in | |||
| 2252 | the middle of a multicolumn character such as a tab, point moves to the | 2252 | the middle of a multicolumn character such as a tab, point moves to the |
| 2253 | end of that character. However, if @var{force} is non-@code{nil}, and | 2253 | end of that character. However, if @var{force} is non-@code{nil}, and |
| 2254 | @var{column} is in the middle of a tab, then @code{move-to-column} | 2254 | @var{column} is in the middle of a tab, then @code{move-to-column} |
| 2255 | converts the tab into spaces so that it can move precisely to column | 2255 | either converts the tab into spaces (when @code{indent-tabs-mode} is |
| 2256 | @var{column}. Other multicolumn characters can cause anomalies despite | 2256 | @code{nil}), or inserts enough spaces before it (otherwise), so that |
| 2257 | @var{force}, since there is no way to split them. | 2257 | point can move precisely to column @var{column}. Other multicolumn |
| 2258 | characters can cause anomalies despite @var{force}, since there is no | ||
| 2259 | way to split them. | ||
| 2258 | 2260 | ||
| 2259 | The argument @var{force} also has an effect if the line isn't long | 2261 | The argument @var{force} also has an effect if the line isn't long |
| 2260 | enough to reach column @var{column}; if it is @code{t}, that means to | 2262 | enough to reach column @var{column}; if it is @code{t}, that means to |
diff --git a/lisp/files.el b/lisp/files.el index 8477c227bcc..8fa7f16de01 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -4110,6 +4110,52 @@ This function returns either: | |||
| 4110 | (declare-function map-merge-with "map" (type function &rest maps)) | 4110 | (declare-function map-merge-with "map" (type function &rest maps)) |
| 4111 | (declare-function map-merge "map" (type &rest maps)) | 4111 | (declare-function map-merge "map" (type &rest maps)) |
| 4112 | 4112 | ||
| 4113 | (defun dir-locals--get-sort-score (node) | ||
| 4114 | "Return a number used for sorting the definitions of dir locals. | ||
| 4115 | NODE is assumed to be a cons cell where the car is either a | ||
| 4116 | string or a symbol representing a mode name. | ||
| 4117 | |||
| 4118 | If it is a mode then the the depth of the mode (ie, how many | ||
| 4119 | parents that mode has) will be returned. | ||
| 4120 | |||
| 4121 | If it is a string then the length of the string plus 1000 will be | ||
| 4122 | returned. | ||
| 4123 | |||
| 4124 | Otherwise it returns -1. | ||
| 4125 | |||
| 4126 | That way the value can be used to sort the list such that deeper | ||
| 4127 | modes will be after the other modes. This will be followed by | ||
| 4128 | directory entries in order of length. If the entries are all | ||
| 4129 | applied in order then that means the more specific modes will | ||
| 4130 | override the values specified by the earlier modes and directory | ||
| 4131 | variables will override modes." | ||
| 4132 | (let ((key (car node))) | ||
| 4133 | (cond ((null key) -1) | ||
| 4134 | ((symbolp key) | ||
| 4135 | (let ((mode key) | ||
| 4136 | (depth 0)) | ||
| 4137 | (while (setq mode (get mode 'derived-mode-parent)) | ||
| 4138 | (setq depth (1+ depth))) | ||
| 4139 | depth)) | ||
| 4140 | ((stringp key) | ||
| 4141 | (+ 1000 (length key))) | ||
| 4142 | (t -2)))) | ||
| 4143 | |||
| 4144 | (defun dir-locals--sort-variables (variables) | ||
| 4145 | "Sorts VARIABLES so that applying them in order has the right effect. | ||
| 4146 | The variables are compared by dir-locals--get-sort-score. | ||
| 4147 | Directory entries are then recursively sorted using the same | ||
| 4148 | criteria." | ||
| 4149 | (setq variables (sort variables | ||
| 4150 | (lambda (a b) | ||
| 4151 | (< (dir-locals--get-sort-score a) | ||
| 4152 | (dir-locals--get-sort-score b))))) | ||
| 4153 | (dolist (n variables) | ||
| 4154 | (when (stringp (car n)) | ||
| 4155 | (setcdr n (dir-locals--sort-variables (cdr n))))) | ||
| 4156 | |||
| 4157 | variables) | ||
| 4158 | |||
| 4113 | (defun dir-locals-read-from-dir (dir) | 4159 | (defun dir-locals-read-from-dir (dir) |
| 4114 | "Load all variables files in DIR and register a new class and instance. | 4160 | "Load all variables files in DIR and register a new class and instance. |
| 4115 | DIR is the absolute name of a directory which must contain at | 4161 | DIR is the absolute name of a directory which must contain at |
| @@ -4147,6 +4193,7 @@ Return the new class name, which is a symbol named DIR." | |||
| 4147 | variables | 4193 | variables |
| 4148 | newvars)))))) | 4194 | newvars)))))) |
| 4149 | (setq success latest)) | 4195 | (setq success latest)) |
| 4196 | (setq variables (dir-locals--sort-variables variables)) | ||
| 4150 | (dir-locals-set-class-variables class-name variables) | 4197 | (dir-locals-set-class-variables class-name variables) |
| 4151 | (dir-locals-set-directory-class dir class-name success) | 4198 | (dir-locals-set-directory-class dir class-name success) |
| 4152 | class-name)) | 4199 | class-name)) |
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index f31e0b45d20..05ef29a1141 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el | |||
| @@ -101,9 +101,9 @@ don't define this value." | |||
| 101 | 101 | ||
| 102 | (defcustom smtpmail-stream-type nil | 102 | (defcustom smtpmail-stream-type nil |
| 103 | "Type of SMTP connections to use. | 103 | "Type of SMTP connections to use. |
| 104 | This may be either nil (possibly upgraded to STARTTLS if possible), | 104 | This may be either nil (upgrade with STARTTLS if possible), |
| 105 | or `starttls' (refuse to send if STARTTLS isn't available), or `plain' | 105 | `starttls' (refuse to send if STARTTLS isn't available), |
| 106 | \(never use STARTTLS), or `ssl' (to use TLS/SSL)." | 106 | `plain' (never use STARTTLS), or `ssl' (to use TLS/SSL)." |
| 107 | :version "24.1" | 107 | :version "24.1" |
| 108 | :group 'smtpmail | 108 | :group 'smtpmail |
| 109 | :type '(choice (const :tag "Possibly upgrade to STARTTLS" nil) | 109 | :type '(choice (const :tag "Possibly upgrade to STARTTLS" nil) |
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el index 6f80912dd58..8da9f5ca287 100644 --- a/lisp/nxml/nxml-mode.el +++ b/lisp/nxml/nxml-mode.el | |||
| @@ -2379,7 +2379,9 @@ With a prefix argument, inserts the character directly." | |||
| 2379 | (put 'nxml-char-ref 'evaporate t) | 2379 | (put 'nxml-char-ref 'evaporate t) |
| 2380 | 2380 | ||
| 2381 | (defun nxml-char-ref-display-extra (start end n) | 2381 | (defun nxml-char-ref-display-extra (start end n) |
| 2382 | (when nxml-char-ref-extra-display | 2382 | (when (and ;; Displaying literal newline is unhelpful. |
| 2383 | (not (eql n ?\n)) | ||
| 2384 | nxml-char-ref-extra-display) | ||
| 2383 | (let ((name (or (get-char-code-property n 'name) | 2385 | (let ((name (or (get-char-code-property n 'name) |
| 2384 | (get-char-code-property n 'old-name))) | 2386 | (get-char-code-property n 'old-name))) |
| 2385 | (glyph-string (and nxml-char-ref-display-glyph-flag | 2387 | (glyph-string (and nxml-char-ref-display-glyph-flag |
diff --git a/lisp/nxml/nxml-rap.el b/lisp/nxml/nxml-rap.el index 2bd758be3a5..21dbaded25a 100644 --- a/lisp/nxml/nxml-rap.el +++ b/lisp/nxml/nxml-rap.el | |||
| @@ -35,35 +35,25 @@ | |||
| 35 | ;; | 35 | ;; |
| 36 | ;; Our strategy is to keep track of just the problematic things. | 36 | ;; Our strategy is to keep track of just the problematic things. |
| 37 | ;; Specifically, we keep track of all comments, CDATA sections and | 37 | ;; Specifically, we keep track of all comments, CDATA sections and |
| 38 | ;; processing instructions in the instance. We do this by marking all | 38 | ;; processing instructions in the instance. We do this by marking |
| 39 | ;; except the first character of these with a non-nil nxml-inside text | 39 | ;; the first character of these with the generic string syntax by setting |
| 40 | ;; property. The value of the nxml-inside property is comment, | 40 | ;; a 'syntax-table' text property in `sgml-syntax-propertize'. |
| 41 | ;; cdata-section or processing-instruction. The first character does | ||
| 42 | ;; not have the nxml-inside property so we can find the beginning of | ||
| 43 | ;; the construct by looking for a change in a text property value | ||
| 44 | ;; (Emacs provides primitives for this). We use text properties | ||
| 45 | ;; rather than overlays, since the implementation of overlays doesn't | ||
| 46 | ;; look like it scales to large numbers of overlays in a buffer. | ||
| 47 | ;; | ||
| 48 | ;; We don't in fact track all these constructs, but only track them in | ||
| 49 | ;; some initial part of the instance. | ||
| 50 | ;; | 41 | ;; |
| 51 | ;; Thus to parse some random point in the file we first ensure that we | 42 | ;; Thus to parse some random point in the file we first ensure that we |
| 52 | ;; have scanned up to that point. Then we search backwards for a | 43 | ;; have scanned up to that point. Then we search backwards for a <. |
| 53 | ;; <. Then we check whether the < has an nxml-inside property. If it | 44 | ;; Then we check whether the < has the generic string syntax. If it |
| 54 | ;; does we go backwards to first character that does not have an | 45 | ;; does we go backwards to first character of the generic string (this |
| 55 | ;; nxml-inside property (this character must be a <). Then we start | 46 | ;; character must be a <). Then we start parsing forward from the < |
| 56 | ;; parsing forward from the < we have found. | 47 | ;; we have found. |
| 57 | ;; | 48 | ;; |
| 58 | ;; The prolog has to be parsed specially, so we also keep track of the | 49 | ;; The prolog has to be parsed specially, so we also keep track of the |
| 59 | ;; end of the prolog in `nxml-prolog-end'. The prolog is reparsed on | 50 | ;; end of the prolog in `nxml-prolog-end'. The prolog is reparsed on |
| 60 | ;; every change to the prolog. This won't work well if people try to | 51 | ;; every change to the prolog. This won't work well if people try to |
| 61 | ;; edit huge internal subsets. Hopefully that will be rare. | 52 | ;; edit huge internal subsets. Hopefully that will be rare. |
| 62 | ;; | 53 | ;; |
| 63 | ;; We keep track of the changes by adding to the buffer's | 54 | ;; We rely on the `syntax-propertize-function' machinery to keep track |
| 64 | ;; after-change-functions hook. Scanning is also done as a | 55 | ;; of the changes in the buffer. Fontification also relies on correct |
| 65 | ;; prerequisite to fontification by adding to fontification-functions | 56 | ;; `syntax-table' properties. This means that scanning for these |
| 66 | ;; (in the same way as jit-lock). This means that scanning for these | ||
| 67 | ;; constructs had better be quick. Fortunately it is. Firstly, the | 57 | ;; constructs had better be quick. Fortunately it is. Firstly, the |
| 68 | ;; typical proportion of comments, CDATA sections and processing | 58 | ;; typical proportion of comments, CDATA sections and processing |
| 69 | ;; instructions is small relative to other things. Secondly, to scan | 59 | ;; instructions is small relative to other things. Secondly, to scan |
| @@ -79,7 +69,15 @@ | |||
| 79 | "Integer giving position following end of the prolog.") | 69 | "Integer giving position following end of the prolog.") |
| 80 | 70 | ||
| 81 | (defsubst nxml-get-inside (pos) | 71 | (defsubst nxml-get-inside (pos) |
| 82 | (save-excursion (nth 8 (syntax-ppss pos)))) | 72 | "Return non-nil if inside comment, CDATA, or PI." |
| 73 | (let ((ppss (save-excursion (syntax-ppss pos)))) | ||
| 74 | (or | ||
| 75 | ;; Inside comment. | ||
| 76 | (nth 4 ppss) | ||
| 77 | ;; Inside "generic" string which is used for CDATA, and PI. | ||
| 78 | ;; "Normal" double and single quoted strings are used for | ||
| 79 | ;; attribute values. | ||
| 80 | (eq t (nth 3 ppss))))) | ||
| 83 | 81 | ||
| 84 | (defun nxml-inside-end (pos) | 82 | (defun nxml-inside-end (pos) |
| 85 | "Return the end of the inside region containing POS. | 83 | "Return the end of the inside region containing POS. |
diff --git a/lisp/server.el b/lisp/server.el index d8c7c313ef1..436a44a7e94 100644 --- a/lisp/server.el +++ b/lisp/server.el | |||
| @@ -1650,7 +1650,14 @@ be a cons cell (LINENUMBER . COLUMNNUMBER)." | |||
| 1650 | (frame-terminal)))) | 1650 | (frame-terminal)))) |
| 1651 | 'nomini 'visible (selected-window)))) | 1651 | 'nomini 'visible (selected-window)))) |
| 1652 | (condition-case nil | 1652 | (condition-case nil |
| 1653 | (switch-to-buffer next-buffer) | 1653 | ;; If the client specified a new buffer position, |
| 1654 | ;; treat that as an explicit point-move command, and | ||
| 1655 | ;; override switch-to-buffer-preserve-window-point. | ||
| 1656 | (let ((switch-to-buffer-preserve-window-point | ||
| 1657 | (if filepos | ||
| 1658 | nil | ||
| 1659 | switch-to-buffer-preserve-window-point))) | ||
| 1660 | (switch-to-buffer next-buffer)) | ||
| 1654 | ;; After all the above, we might still have ended up with | 1661 | ;; After all the above, we might still have ended up with |
| 1655 | ;; a minibuffer/dedicated-window (if there's no other). | 1662 | ;; a minibuffer/dedicated-window (if there's no other). |
| 1656 | (error (pop-to-buffer next-buffer))))))) | 1663 | (error (pop-to-buffer next-buffer))))))) |
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 9e3be99af14..6dc1b9e727e 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el | |||
| @@ -96,24 +96,20 @@ a DOCTYPE or an XML declaration." | |||
| 96 | `text-mode-hook' is run first." | 96 | `text-mode-hook' is run first." |
| 97 | :type 'hook) | 97 | :type 'hook) |
| 98 | 98 | ||
| 99 | ;; As long as Emacs's syntax can't be complemented with predicates to context | 99 | ;; The official handling of "--" is complicated in SGML, and |
| 100 | ;; sensitively confirm the syntax of characters, we have to live with this | 100 | ;; historically not well supported by browser HTML parsers. |
| 101 | ;; kludgy kind of tradeoff. | 101 | ;; Recommendations for writing HTML comments is to use <!--...--> |
| 102 | (defvar sgml-specials '(?\") | 102 | ;; (where ... doesn't contain "--") to avoid the complications |
| 103 | ;; altogether (XML goes even further by requiring this in the spec). | ||
| 104 | ;; So there is probably no need to handle it "correctly". | ||
| 105 | (defvar sgml-specials '(?\" ?\') | ||
| 103 | "List of characters that have a special meaning for SGML mode. | 106 | "List of characters that have a special meaning for SGML mode. |
| 104 | This list is used when first loading the `sgml-mode' library. | 107 | This list is used when first loading the `sgml-mode' library. |
| 105 | The supported characters and potential disadvantages are: | 108 | The supported characters are ?\\\", ?\\=', and ?-. |
| 106 | 109 | ||
| 107 | ?\\\" Makes \" in text start a string. | 110 | Including ?- makes double dashes into comment delimiters, but |
| 108 | ?\\=' Makes \\=' in text start a string. | 111 | they are really only supposed to delimit comments within DTD |
| 109 | ?- Makes -- in text start a comment. | 112 | definitions. So we normally turn it off.") |
| 110 | |||
| 111 | When only one of ?\\\" or ?\\=' are included, \"\\='\" or \\='\"\\=', as can be found in | ||
| 112 | DTDs, start a string. To partially avoid this problem this also makes these | ||
| 113 | self insert as named entities depending on `sgml-quick-keys'. | ||
| 114 | |||
| 115 | Including ?- has the problem of affecting dashes that have nothing to do | ||
| 116 | with comments, so we normally turn it off.") | ||
| 117 | 113 | ||
| 118 | (defvar sgml-quick-keys nil | 114 | (defvar sgml-quick-keys nil |
| 119 | "Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil. | 115 | "Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil. |
| @@ -343,21 +339,12 @@ Any terminating `>' or `/' is not matched.") | |||
| 343 | ("--[ \t\n]*\\(>\\)" (1 "> b")) | 339 | ("--[ \t\n]*\\(>\\)" (1 "> b")) |
| 344 | ("\\(<\\)[?!]" (1 (prog1 "|>" | 340 | ("\\(<\\)[?!]" (1 (prog1 "|>" |
| 345 | (sgml-syntax-propertize-inside end)))) | 341 | (sgml-syntax-propertize-inside end)))) |
| 346 | ;; Double quotes outside of tags should not introduce strings which end up | 342 | ;; Quotes outside of tags should not introduce strings. |
| 347 | ;; hiding tags. We used to test every double quote and mark it as "." | 343 | ;; Be careful to call `syntax-ppss' on a position before the one we're |
| 348 | ;; if it's outside of tags, but there are too many double quotes and | 344 | ;; going to change, so as not to need to flush the data we just computed. |
| 349 | ;; the resulting number of calls to syntax-ppss made it too slow | 345 | ("[\"']" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) |
| 350 | ;; (bug#33887), so we're now careful to leave alone any pair | 346 | (goto-char (match-end 0))) |
| 351 | ;; of quotes that doesn't hold a < or > char, which is the vast majority. | 347 | (string-to-syntax "."))))))) |
| 352 | ("\\(\"\\)[^\"<>]*[<>\"]" | ||
| 353 | (1 (unless (eq ?\" (char-before)) | ||
| 354 | ;; Be careful to call `syntax-ppss' on a position before the one | ||
| 355 | ;; we're going to change, so as not to need to flush the data we | ||
| 356 | ;; just computed. | ||
| 357 | (if (prog1 (zerop (car (syntax-ppss (match-beginning 0)))) | ||
| 358 | (goto-char (1- (match-end 0)))) | ||
| 359 | (string-to-syntax "."))))) | ||
| 360 | ))) | ||
| 361 | 348 | ||
| 362 | (defun sgml-syntax-propertize (start end) | 349 | (defun sgml-syntax-propertize (start end) |
| 363 | "Syntactic keywords for `sgml-mode'." | 350 | "Syntactic keywords for `sgml-mode'." |
diff --git a/src/indent.c b/src/indent.c index c76e6b7b4bd..90d8b1ce8e9 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. | |||
| 983 | If it's past end of line, point goes to end of line. | 983 | If it's past end of line, point goes to end of line. |
| 984 | 984 | ||
| 985 | Optional second argument FORCE non-nil means if COLUMN is in the | 985 | Optional second argument FORCE non-nil means if COLUMN is in the |
| 986 | middle of a tab character, change it to spaces. | 986 | middle of a tab character, either change it to spaces (when |
| 987 | In addition, if FORCE is t, and the line is too short to reach | 987 | `indent-tabs-mode' is nil), or insert enough spaces before it to reach |
| 988 | COLUMN, add spaces/tabs to get there. | 988 | COLUMN (otherwise). In addition, if FORCE is t, and the line is too short |
| 989 | to reach COLUMN, add spaces/tabs to get there. | ||
| 989 | 990 | ||
| 990 | The return value is the current column. */) | 991 | The return value is the current column. */) |
| 991 | (Lisp_Object column, Lisp_Object force) | 992 | (Lisp_Object column, Lisp_Object force) |
diff --git a/test/lisp/nxml/nxml-mode-tests.el b/test/lisp/nxml/nxml-mode-tests.el new file mode 100644 index 00000000000..92744be619d --- /dev/null +++ b/test/lisp/nxml/nxml-mode-tests.el | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | ;;; nxml-mode-tests.el --- Test NXML Mode -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2019 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 6 | ;; it under the terms of the GNU General Public License as published by | ||
| 7 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 8 | ;; (at your option) any later version. | ||
| 9 | |||
| 10 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | ;; GNU General Public License for more details. | ||
| 14 | |||
| 15 | ;; You should have received a copy of the GNU General Public License | ||
| 16 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 17 | |||
| 18 | ;;; Code: | ||
| 19 | |||
| 20 | (require 'ert) | ||
| 21 | (require 'nxml-mode) | ||
| 22 | |||
| 23 | (defun nxml-mode-tests-correctly-indented-string (str) | ||
| 24 | (with-temp-buffer | ||
| 25 | (nxml-mode) | ||
| 26 | (insert str) | ||
| 27 | (indent-region (point-min) (point-max)) | ||
| 28 | (equal (buffer-string) str))) | ||
| 29 | |||
| 30 | (ert-deftest nxml-indent-line-after-attribute () | ||
| 31 | (should (nxml-mode-tests-correctly-indented-string " | ||
| 32 | <settings | ||
| 33 | xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\" | ||
| 34 | xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" | ||
| 35 | xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0 | ||
| 36 | https://maven.apache.org/xsd/settings-1.0.0.xsd\"> | ||
| 37 | <mirrors> | ||
| 38 | ... | ||
| 39 | </mirrors> | ||
| 40 | </settings> | ||
| 41 | ")) | ||
| 42 | (should (nxml-mode-tests-correctly-indented-string "\ | ||
| 43 | <x> | ||
| 44 | <abc xx=\"x/x/x/x/x/x/x/ | ||
| 45 | y/y/y/y/y/y/ | ||
| 46 | \"> | ||
| 47 | <zzz/> | ||
| 48 | </abc> | ||
| 49 | <nl> </nl> | ||
| 50 | </x> | ||
| 51 | "))) | ||
| 52 | |||
| 53 | (ert-deftest nxml-balanced-close-start-tag-inline () | ||
| 54 | (with-temp-buffer | ||
| 55 | (nxml-mode) | ||
| 56 | (insert "<a><b c=\"\"</a>") | ||
| 57 | (search-backward "</a>") | ||
| 58 | (nxml-balanced-close-start-tag-inline) | ||
| 59 | (should (equal (buffer-string) "<a><b c=\"\"></b></a>")))) | ||
| 60 | |||
| 61 | (ert-deftest nxml-mode-font-lock-quotes () | ||
| 62 | (with-temp-buffer | ||
| 63 | (nxml-mode) | ||
| 64 | (insert "<x a=\"dquote attr\" b='squote attr'>\"dquote text\"'squote text'</x>") | ||
| 65 | (font-lock-ensure) | ||
| 66 | (let ((squote-txt-pos (search-backward "squote text")) | ||
| 67 | (dquote-txt-pos (search-backward "dquote text")) | ||
| 68 | (squote-att-pos (search-backward "squote attr")) | ||
| 69 | (dquote-att-pos (search-backward "dquote attr"))) | ||
| 70 | ;; Just make sure that each quote uses the same face for quoted | ||
| 71 | ;; attribute values, and a different face for quoted text | ||
| 72 | ;; outside tags. Don't test `font-lock-string-face' vs | ||
| 73 | ;; `nxml-attribute-value' here. | ||
| 74 | (should (equal (get-text-property squote-att-pos 'face) | ||
| 75 | (get-text-property dquote-att-pos 'face))) | ||
| 76 | (should (equal (get-text-property squote-txt-pos 'face) | ||
| 77 | (get-text-property dquote-txt-pos 'face))) | ||
| 78 | (should-not (equal (get-text-property squote-txt-pos 'face) | ||
| 79 | (get-text-property dquote-att-pos 'face)))))) | ||
| 80 | |||
| 81 | (provide 'nxml-mode-tests) | ||
| 82 | ;;; 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 61ae87e36db..4355e1c8658 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." | |||
| 125 | (should (string= content (buffer-string)))))) | 125 | (should (string= content (buffer-string)))))) |
| 126 | 126 | ||
| 127 | (ert-deftest sgml-delete-tag-bug-8203-should-not-delete-apostrophe () | 127 | (ert-deftest sgml-delete-tag-bug-8203-should-not-delete-apostrophe () |
| 128 | :expected-result :failed | ||
| 129 | (sgml-with-content | 128 | (sgml-with-content |
| 130 | "<title>Winter is comin'</title>" | 129 | "<title>Winter is comin'</title>" |
| 131 | (sgml-delete-tag 1) | 130 | (sgml-delete-tag 1) |