[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/typescript-mode 4e3850dd2a 105/222: Remove logic handling
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/typescript-mode 4e3850dd2a 105/222: Remove logic handling preprocessor macros |
Date: |
Sun, 6 Feb 2022 16:59:22 -0500 (EST) |
branch: elpa/typescript-mode
commit 4e3850dd2a901c6e1841a005852c65b1373b8601
Author: Wilfred Hughes <Wilfred.Hughes@man.com>
Commit: Wilfred Hughes <Wilfred.Hughes@man.com>
Remove logic handling preprocessor macros
TypeScript does not have preprocessor macros. It was proposed in
https://github.com/Microsoft/TypeScript/issues/4691 but never added
to the language.
---
typescript-mode.el | 100 ++++++-----------------------------------------------
1 file changed, 10 insertions(+), 90 deletions(-)
diff --git a/typescript-mode.el b/typescript-mode.el
index 6d129e9a3b..a2d8991911 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:
@@ -82,15 +82,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\\)\\_>")
@@ -271,11 +262,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) "\\_>"))
@@ -869,11 +855,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))
@@ -888,22 +870,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)
@@ -922,11 +897,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))
@@ -940,22 +911,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
@@ -1345,21 +1310,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))
@@ -1470,30 +1420,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
@@ -1506,8 +1439,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
@@ -1751,13 +1682,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)
@@ -2318,7 +2242,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\\_>[^:]"))
@@ -2394,10 +2317,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))))
- [nongnu] elpa/typescript-mode 54f14c4827 202/222: Update README.md, (continued)
- [nongnu] elpa/typescript-mode 54f14c4827 202/222: Update README.md, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b369d7d251 206/222: Merge pull request #147 from ltrel/typo-fixes, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode bc37bc4b15 176/222: Fix another member expression infinite loop., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1e9fc35cb9 210/222: Make cask and emacs locations overridable., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 96800ed070 208/222: Migrate build to use proper tasks and new source for Emacs, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e824162051 222/222: Merge pull request #159 from tancnle/fix-cl-deprecation-warnings, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5b0487aae8 085/222: Fix the Emacs regex used for highlighting TS regexes., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2cd997a8d5 102/222: Fix typescript--backward-to-parameter-list, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 2815dd1b4b 098/222: Add option to support indented case-statements. Fixes #23 (#66), ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 861d5983b6 090/222: Make the comment-start and comment-end variables local., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4e3850dd2a 105/222: Remove logic handling preprocessor macros,
ELPA Syncer <=
- [nongnu] elpa/typescript-mode 32f5034e9d 127/222: Extract tests as general tests, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode e15e2bfa1a 131/222: Add jsdoc tests, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c0f11efdfd 143/222: Fixing typescript--forward-expression for multiline indented string, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode a0f2c3ebd4 164/222: Reimplement template auto conversion as a post-self-insert-hook, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode b44b75dbe1 172/222: Add test case for infinite loop, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 5bf30fe8d6 175/222: Add member expressions tests involving type parameters., ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 1c27fb09ed 220/222: Fix cl deprecation warning, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode dd832751ab 217/222: Merge pull request #156 from zkry/fix-dot-after-exclamation-indentation, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode 4249a20d6d 187/222: Added file for indent test case, ELPA Syncer, 2022/02/06
- [nongnu] elpa/typescript-mode c5e7788ce9 044/222: Merge pull request #28 from ananthakumaran/testing, ELPA Syncer, 2022/02/06