emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master e99a124: * lisp/textmodes/sgml-mode.el: Try and fix


From: Stefan Monnier
Subject: [Emacs-diffs] master e99a124: * lisp/textmodes/sgml-mode.el: Try and fix bug#33887.
Date: Thu, 17 Jan 2019 18:25:07 -0500 (EST)

branch: master
commit e99a1241108433a63879a2430d55f2a1910d3c89
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp/textmodes/sgml-mode.el: Try and fix bug#33887.
    
    Remove redundant :group args.
    (sgml-syntax-propertize-rules): Speed up processing of most double quotes.
---
 lisp/textmodes/sgml-mode.el | 60 +++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 32 deletions(-)

diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 6c46efb..e49144e 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -46,8 +46,7 @@
 
 (defcustom sgml-basic-offset 2
   "Specifies the basic indentation level for `sgml-indent-line'."
-  :type 'integer
-  :group 'sgml)
+  :type 'integer)
 
 (defcustom sgml-attribute-offset 0
   "Specifies a delta for attribute indentation in `sgml-indent-line'.
@@ -65,16 +64,14 @@ When 2, attribute indentation looks like this:
   </element>"
   :version "25.1"
   :type 'integer
-  :safe 'integerp
-  :group 'sgml)
+  :safe 'integerp)
 
 (defcustom sgml-xml-mode nil
   "When non-nil, tag insertion functions will be XML-compliant.
 It is set to be buffer-local when the file has
 a DOCTYPE or an XML declaration."
   :type 'boolean
-  :version "22.1"
-  :group 'sgml)
+  :version "22.1")
 
 (defvaralias 'sgml-transformation 'sgml-transformation-function)
 
@@ -89,8 +86,7 @@ a DOCTYPE or an XML declaration."
                    (and (derived-mode-p 'sgml-mode)
                         (not sgml-xml-mode)
                         (setq skeleton-transformation-function val))))
-               (buffer-list)))
-  :group 'sgml)
+               (buffer-list))))
 
 (put 'sgml-transformation-function 'variable-interactive
      "aTransformation function: ")
@@ -98,7 +94,6 @@ a DOCTYPE or an XML declaration."
 (defcustom sgml-mode-hook nil
   "Hook run by command `sgml-mode'.
 `text-mode-hook' is run first."
-  :group 'sgml
   :type 'hook)
 
 ;; As long as Emacs's syntax can't be complemented with predicates to context
@@ -211,8 +206,7 @@ This takes effect when first loading the `sgml-mode' 
library.")
 
 (defcustom sgml-name-8bit-mode nil
   "When non-nil, insert non-ASCII characters as named entities."
-  :type 'boolean
-  :group 'sgml)
+  :type 'boolean)
 
 (defvar sgml-char-names
   [nil nil nil nil nil nil nil nil
@@ -282,8 +276,7 @@ Currently, only Latin-1 characters are supported.")
 The file name of current buffer file name will be appended to this,
 separated by a space."
   :type 'string
-  :version "21.1"
-  :group 'sgml)
+  :version "21.1")
 
 (defvar sgml-saved-validate-command nil
   "The command last used to validate in this buffer.")
@@ -292,8 +285,7 @@ separated by a space."
 ;; so use a small distance here.
 (defcustom sgml-slash-distance 1000
   "If non-nil, is the maximum distance to search for matching `/'."
-  :type '(choice (const nil) integer)
-  :group 'sgml)
+  :type '(choice (const nil) integer))
 
 (defconst sgml-namespace-re "[_[:alpha:]][-_.[:alnum:]]*")
 (defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*")
@@ -305,8 +297,7 @@ Any terminating `>' or `/' is not matched.")
 
 (defface sgml-namespace
   '((t (:inherit font-lock-builtin-face)))
-  "`sgml-mode' face used to highlight the namespace part of identifiers."
-  :group 'sgml)
+  "`sgml-mode' face used to highlight the namespace part of identifiers.")
 (defvar sgml-namespace-face 'sgml-namespace)
 
 ;; internal
@@ -352,12 +343,21 @@ 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.
-     ;; 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 ".")))))))
+     ;; Double quotes outside of tags should not introduce strings which end up
+     ;; hiding tags.  We used to test every double quote and mark it as "."
+     ;; if it's outside of tags, but there are too many double quotes and
+     ;; the resulting number of calls to syntax-ppss made it too slow
+     ;; (bug#33887), so we're now careful to leave alone any pair
+     ;; of quotes that doesn't hold a < or > char, which is the vast majority.
+     ("\\(\"\\)[^\"<>]*[<>\"]"
+      (1 (unless (eq ?\" (char-before))
+           ;; 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.
+           (if (prog1 (zerop (car (syntax-ppss (match-beginning 0))))
+                 (goto-char (1- (match-end 0))))
+               (string-to-syntax ".")))))
+     )))
 
 (defun sgml-syntax-propertize (start end)
   "Syntactic keywords for `sgml-mode'."
@@ -421,8 +421,7 @@ The attribute alist is made up as
 ATTRIBUTERULE is a list of optionally t (no value when no input) followed by
 an optional alist of possible values."
   :type '(repeat (cons (string :tag "Tag Name")
-                      (repeat :tag "Tag Rule" sexp)))
-  :group 'sgml)
+                      (repeat :tag "Tag Rule" sexp))))
 (put 'sgml-tag-alist 'risky-local-variable t)
 
 (defcustom sgml-tag-help
@@ -434,8 +433,7 @@ an optional alist of possible values."
     ("!entity" . "Entity (macro) declaration"))
   "Alist of tag name and short description."
   :type '(repeat (cons (string :tag "Tag Name")
-                      (string :tag "Description")))
-  :group 'sgml)
+                      (string :tag "Description"))))
 
 (defvar sgml-empty-tags nil
   "List of tags whose !ELEMENT definition says EMPTY.")
@@ -461,7 +459,7 @@ an optional alist of possible values."
               nil t)
          (string-match "X\\(HT\\)?ML" (match-string 3))))))
 
-(defvar v2)                            ; free for skeleton
+(with-no-warnings (defvar v2))                         ; free for skeleton
 
 (defun sgml-comment-indent-new-line (&optional soft)
   (let ((comment-start "-- ")
@@ -1722,7 +1720,6 @@ Currently just returns (EMPTY-TAGS UNCLOSED-TAGS)."
 (defcustom html-mode-hook nil
   "Hook run by command `html-mode'.
 `text-mode-hook' and `sgml-mode-hook' are run first."
-  :group 'sgml
   :type 'hook
   :options '(html-autoview-mode))
 
@@ -2381,10 +2378,9 @@ HTML Autoview mode is a buffer-local minor mode for use 
with
 `html-mode'.  If enabled, saving the file automatically runs
 `browse-url-of-buffer' to view it."
   nil nil nil
-  :group 'sgml
   (if html-autoview-mode
-      (add-hook 'after-save-hook 'browse-url-of-buffer nil t)
-    (remove-hook 'after-save-hook 'browse-url-of-buffer t)))
+      (add-hook 'after-save-hook #'browse-url-of-buffer nil t)
+    (remove-hook 'after-save-hook #'browse-url-of-buffer t)))
 
 
 (define-skeleton html-href-anchor



reply via email to

[Prev in Thread] Current Thread [Next in Thread]