emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/typescript-mode 7a5c74d88e 109/222: Merge pull request #72


From: ELPA Syncer
Subject: [nongnu] elpa/typescript-mode 7a5c74d88e 109/222: Merge pull request #72 from Wilfred/remove_cpp
Date: Sun, 6 Feb 2022 16:59:22 -0500 (EST)

branch: elpa/typescript-mode
commit 7a5c74d88e3c5513cc4431a837003736f905a75e
Merge: a09e9c78f9 4e3850dd2a
Author: Jostein Kjønigsen <jostein@kjonigsen.net>
Commit: GitHub <noreply@github.com>

    Merge pull request #72 from Wilfred/remove_cpp
    
    Remove logic handling preprocessor macros
---
 typescript-mode.el | 100 ++++++-----------------------------------------------
 1 file changed, 10 insertions(+), 90 deletions(-)

diff --git a/typescript-mode.el b/typescript-mode.el
index 3d6022dce2..17d64538d7 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -38,7 +38,7 @@
 ;; The main features of this typescript mode are syntactic
 ;; highlighting (enabled with `font-lock-mode' or
 ;; `global-font-lock-mode'), automatic indentation and filling of
-;; comments and C preprocessor fontification
+;; comments.
 ;;
 ;;
 ;; General Remarks:
@@ -77,15 +77,6 @@
   (concat typescript--name-re "\\(?:\\." typescript--name-re "\\)*")
   "Regexp matching a dot-separated sequence of typescript names.")
 
-(defconst typescript--cpp-name-re typescript--name-re
-  "Regexp matching a C preprocessor name.")
-
-(defconst typescript--opt-cpp-start "^\\s-*#\\s-*\\([[:alnum:]]+\\)"
-  "Regexp matching the prefix of a cpp directive.
-This includes the directive name, or nil in languages without
-preprocessor support.  The first submatch surrounds the directive
-name.")
-
 (defconst typescript--plain-method-re
   (concat "^\\s-*?\\(" typescript--dotted-name-re "\\)\\.prototype"
           "\\.\\(" typescript--name-re "\\)\\s-*?=\\s-*?\\(function\\)\\_>")
@@ -266,11 +257,6 @@ Match group 1 is the name of the function.")
   "Regexp matching a line in the typescript form \"var MUMBLE = function\".
 Match group 1 is MUMBLE.")
 
-(defconst typescript--macro-decl-re
-  (concat "^\\s-*#\\s-*define\\s-+\\(" typescript--cpp-name-re "\\)\\s-*(")
-  "Regexp matching a CPP macro definition, up to the opening parenthesis.
-Match group 1 is the name of the macro.")
-
 (defun typescript--regexp-opt-symbol (list)
   "Like `regexp-opt', but surround the result with `\\\\_<' and `\\\\_>'."
   (concat "\\_<" (regexp-opt list t) "\\_>"))
@@ -864,11 +850,7 @@ point at BOB."
 (defun typescript--re-search-forward-inner (regexp &optional bound count)
   "Helper function for `typescript--re-search-forward'."
   (let ((parse)
-        str-terminator
-        (orig-macro-end (save-excursion
-                          (when (typescript--beginning-of-macro)
-                            (c-end-of-macro)
-                            (point)))))
+        str-terminator)
     (while (> count 0)
       (re-search-forward regexp bound)
       (setq parse (syntax-ppss))
@@ -883,22 +865,15 @@ point at BOB."
             ((or (nth 4 parse)
                  (and (eq (char-before) ?\/) (eq (char-after) ?\*)))
              (re-search-forward "\\*/"))
-            ((and (not (and orig-macro-end
-                            (<= (point) orig-macro-end)))
-                  (typescript--beginning-of-macro))
-             (c-end-of-macro))
             (t
              (setq count (1- count))))))
   (point))
 
 
 (defun typescript--re-search-forward (regexp &optional bound noerror count)
-  "Search forward, ignoring strings, cpp macros, and comments.
+  "Search forward, ignoring strings and comments.
 This function invokes `re-search-forward', but treats the buffer
-as if strings, cpp macros, and comments have been removed.
-
-If invoked while inside a macro, it treats the contents of the
-macro as normal text."
+as if strings and comments have been removed."
   (let ((saved-point (point))
         (search-expr
          (cond ((null count)
@@ -917,11 +892,7 @@ macro as normal text."
 
 (defun typescript--re-search-backward-inner (regexp &optional bound count)
   "Auxiliary function for `typescript--re-search-backward'."
-  (let ((parse)
-        (orig-macro-start
-         (save-excursion
-           (and (typescript--beginning-of-macro)
-                (point)))))
+  (let ((parse))
     (while (> count 0)
       (re-search-backward regexp bound)
       (when (and (> (point) (point-min))
@@ -935,22 +906,16 @@ macro as normal text."
         (goto-char (nth 8 parse)))
        ((and (eq (char-before) ?/) (eq (char-after) ?*))
         (re-search-backward "/\\*"))
-       ((and (not (and orig-macro-start
-                       (>= (point) orig-macro-start)))
-             (typescript--beginning-of-macro)))
        (t
         (setq count (1- count))))))
   (point))
 
 
 (defun typescript--re-search-backward (regexp &optional bound noerror count)
-  "Search backward, ignoring strings, preprocessor macros, and comments.
+  "Search backward, ignoring strings, and comments.
 
 This function invokes `re-search-backward' but treats the buffer
-as if strings, preprocessor macros, and comments have been
-removed.
-
-If invoked while inside a macro, treat the macro as normal text.
+as if strings and comments have been removed.
 
 IMPORTANT NOTE: searching for \"\\n\" with this function to find
 line breaks will generally not work, because the final newline of
@@ -1340,21 +1305,6 @@ LIMIT defaults to point."
                                 name
                               (typescript--split-name name))))
 
-                    ;; Macro
-                    ((looking-at typescript--macro-decl-re)
-
-                     ;; Macros often contain unbalanced parentheses.
-                     ;; Make sure that h-end is at the textual end of
-                     ;; the macro no matter what the parenthesis say.
-                     (c-end-of-macro)
-                     (typescript--ensure-cache--update-parse)
-
-                     (make-typescript--pitem
-                      :paren-depth (nth 0 parse)
-                      :h-begin orig-match-start
-                      :type 'macro
-                      :name (list (match-string-no-properties 1))))
-
                     ;; "Prototype function" declaration
                     ((looking-at typescript--plain-method-re)
                      (goto-char (match-beginning 3))
@@ -1465,30 +1415,13 @@ LIMIT defaults to point."
 
               (t (typescript--end-of-defun-nested)))))))
 
-(defun typescript--beginning-of-macro (&optional lim)
-  (let ((here (point)))
-    (save-restriction
-      (if lim (narrow-to-region lim (point-max)))
-      (beginning-of-line)
-      (while (eq (char-before (1- (point))) ?\\)
-        (forward-line -1))
-      (back-to-indentation)
-      (if (and (<= (point) here)
-               (looking-at typescript--opt-cpp-start))
-          t
-        (goto-char here)
-        nil))))
-
 (defun typescript--backward-syntactic-ws (&optional lim)
   "Simple implementation of `c-backward-syntactic-ws' for `typescript-mode'."
   (save-restriction
     (when lim (narrow-to-region lim (point-max)))
 
-    (let ((in-macro (save-excursion (typescript--beginning-of-macro)))
-          (pos (point)))
-
-      (while (progn (unless in-macro (typescript--beginning-of-macro))
-                    (forward-comment most-negative-fixnum)
+    (let ((pos (point)))
+      (while (progn (forward-comment most-negative-fixnum)
                     (/= (point)
                         (prog1
                             pos
@@ -1501,8 +1434,6 @@ LIMIT defaults to point."
     (let ((pos (point)))
       (while (progn
                (forward-comment most-positive-fixnum)
-               (when (eq (char-after) ?#)
-                 (c-end-of-macro))
                (/= (point)
                    (prog1
                        pos
@@ -1746,13 +1677,6 @@ and searches for the next token to be highlighted."
 
 (defconst typescript--font-lock-keywords-3
   `(
-    ;; This goes before keywords-2 so it gets used preferentially
-    ;; instead of the keywords in keywords-2. Don't use override
-    ;; because that will override syntactic fontification too, which
-    ;; will fontify commented-out directives as if they weren't
-    ;; commented out.
-    ,@cpp-font-lock-keywords ; from font-lock.el
-
     ,@typescript--font-lock-keywords-2
 
     (typescript--jsdoc-param-matcher (1 'typescript-jsdoc-tag t t)
@@ -2331,7 +2255,6 @@ moved on success."
           ((nth 8 parse-status) 0) ; inside string
           ((typescript--ctrl-statement-indentation))
           ((eq (char-after) ?#) 0)
-          ((save-excursion (typescript--beginning-of-macro)) 4)
           ((nth 1 parse-status)
            (let ((same-indent-p (looking-at "[]})]"))
                  (switch-keyword-p (looking-at 
"\\_<default\\_>\\|\\_<case\\_>[^:]"))
@@ -2407,10 +2330,7 @@ moved on success."
                (typescript--forward-syntactic-ws limit)))
             ((symbol-function 'c-backward-sws)
              (lambda  (&optional limit)
-               (typescript--backward-syntactic-ws limit)))
-            ((symbol-function 'c-beginning-of-macro)
-             (lambda  (&optional limit)
-               (typescript--beginning-of-macro limit))))
+               (typescript--backward-syntactic-ws limit))))
     (let ((fill-paragraph-function 'c-fill-paragraph))
       (c-fill-paragraph justify))))
 



reply via email to

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