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

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

[elpa] externals/csharp-mode bd201c2 171/459: Remove now unused code, mo


From: ELPA Syncer
Subject: [elpa] externals/csharp-mode bd201c2 171/459: Remove now unused code, move log functions to top
Date: Sun, 22 Aug 2021 13:59:20 -0400 (EDT)

branch: externals/csharp-mode
commit bd201c295f7bbacc9df3fed671c5ad4a31cf4ce8
Author: Vasilij Schneidermann <v.schneidermann@gmail.com>
Commit: Vasilij Schneidermann <v.schneidermann@gmail.com>

    Remove now unused code, move log functions to top
---
 csharp-mode.el | 415 +++------------------------------------------------------
 1 file changed, 15 insertions(+), 400 deletions(-)

diff --git a/csharp-mode.el b/csharp-mode.el
index 7f73889..c8461a3 100644
--- a/csharp-mode.el
+++ b/csharp-mode.el
@@ -415,6 +415,21 @@
 ;; csharp-mode utility and feature defuns
 ;; ==================================================================
 
+(defun csharp-time ()
+  "returns the time of day as a string.  Used in the `csharp-log' function."
+  (substring (current-time-string) 11 19)) ;24-hr time
+
+
+(defun csharp-log (level text &rest args)
+  "Log a message at level LEVEL.
+If LEVEL is higher than `csharp-log-level', the message is
+ignored.  Otherwise, it is printed using `message'.
+TEXT is a format control string, and the remaining arguments ARGS
+are the string substitutions (see `format')."
+  (if (<= level csharp-log-level)
+      (let* ((msg (apply 'format text args)))
+        (message "C# %s %s" (csharp-time) msg))))
+
 (defun csharp--at-vsemi-p (&optional pos)
   "Determines if there is a virtual semicolon at POS or point.
 It returns t if at a position where a virtual-semicolon is.
@@ -3372,401 +3387,6 @@ your `csharp-mode-hook' function:
 ;; end of c# code-doc insertion magic
 ;; ==================================================================
 
-
-
-
-;; ==================================================================
-;; c# fontification extensions
-;; ==================================================================
-;; Commentary:
-;;
-;; The purpose of the following code is to fix font-lock for C#,
-;; specifically for the verbatim-literal strings. C# is a cc-mode
-;; language and strings are handled mostly like other c-based
-;; languages. The one exception is the verbatim-literal string, which
-;; uses the syntax @"...".
-;;
-;; `parse-partial-sexp' treats those strings as just regular strings,
-;; with the @ a non-string character.  This is fine, except when the
-;; verblit string ends in a slash, in which case, font-lock breaks from
-;; that point onward in the buffer.
-;;
-;; This is an attempt to fix that.
-;;
-;; The idea is to scan the buffer in full for verblit strings, and apply the
-;; appropriate syntax-table text properties for verblit strings. Also setting
-;; `parse-sexp-lookup-properties' to t tells `parse-partial-sexp'
-;; to use the syntax-table text properties set up by the scan as it does
-;; its parse.
-;;
-;; Also need to re-scan after any changes in the buffer, but on a more
-;; limited region.
-;;
-
-
-;; ;; I don't remember what this is supposed to do,
-;; ;; or how I figured out the value.
-;; ;;
-;; (defconst csharp-font-lock-syntactic-keywords
-;;   '(("\\(@\\)\\(\"\\)[^\"]*\\(\"\\)\\(\"\\)[^\"]*\\(\"\\)[^\"]"
-;;      (1 '(6)) (2 '(7)) (3 '(1)) (4 '(1)) (5 '(7))
-;;                  ))
-;;   "Highlighting of verbatim literal strings. See also the variable
-;;   `font-lock-keywords'.")
-
-
-
-(defun csharp-time ()
-  "returns the time of day as a string.  Used in the `csharp-log' function."
-  (substring (current-time-string) 11 19)) ;24-hr time
-
-
-(defun csharp-log (level text &rest args)
-  "Log a message at level LEVEL.
-If LEVEL is higher than `csharp-log-level', the message is
-ignored.  Otherwise, it is printed using `message'.
-TEXT is a format control string, and the remaining arguments ARGS
-are the string substitutions (see `format')."
-  (if (<= level csharp-log-level)
-      (let* ((msg (apply 'format text args)))
-        (message "C# %s %s" (csharp-time) msg))))
-
-
-
-(defun csharp-max-beginning-of-stmt ()
-  "Return the greater of `c-beginning-of-statement-1' and
-`c-beginning-of-statement' .  I don't understand why both of
-these methods are necessary or why they differ. But they do."
-
-  (let (dash
-        nodash
-        (curpos (point)))
-
-    ;; I think this may need a save-excursion...
-    ;; Calling c-beginning-of-statement-1 resets the point!
-
-    (setq dash (progn (c-beginning-of-statement-1) (point)))
-    (csharp-log 3 "max-bostmt dash(%d)" dash)
-    (goto-char curpos)
-
-    (setq nodash (progn (c-beginning-of-statement 1) (point)))
-    (csharp-log 3 "max-bostmt nodash(%d)" nodash)
-    (goto-char curpos)
-
-    (max dash nodash)))
-
-
-
-
-
-(defun csharp-set-vliteral-syntax-table-properties (beg end)
-  "Scan the buffer text between BEG and END, a verbatim literal
-string, setting and clearing syntax-table text properties where
-necessary.
-
-We need to modify the default syntax-table text property in these cases:
-  (backslash)    - is not an escape inside a verbatim literal string.
-  (double-quote) - can be a literal quote, when doubled.
-
-BEG is the @ delimiter. END is the 'old' position of the ending quote.
-
-see 
http://www.sunsite.ualberta.ca/Documentation/Gnu/emacs-lisp-ref-21-2.7/html_node/elisp_592.html
-for the list of syntax table numeric codes.
-
-"
-
-  (csharp-log 3 "set-vlit-syntax-table:  beg(%d) end(%d)" beg end)
-
-  (if (and (> beg 0) (> end 0))
-
-      (let ((curpos beg)
-            (state 0))
-
-        (c-clear-char-properties beg end 'syntax-table)
-
-        (while (<= curpos end)
-
-          (cond
-           ((= state 0)
-            (if (= (char-after curpos) ?@)
-                (progn
-                  (c-put-char-property curpos 'syntax-table '(6)) ; (6) = 
expression prefix, (3) = symbol
-                  ;;(message (format "set-s-t: prefix pos(%d) chr(%c)" beg 
(char-after beg)))
-                  )
-              )
-            (setq state (+ 1 state)))
-
-           ((= state 1)
-            (if (= (char-after curpos) ?\")
-                (progn
-                  (c-put-char-property curpos 'syntax-table '(7)) ; (7) = 
string quote
-                  ;;(message (format "set-s-t: open quote pos(%d) chr(%c)"
-                  ;; curpos (char-after curpos)))
-                  ))
-            (setq state (+ 1 state)))
-
-           ((= state 2)
-            (cond
-             ;; handle backslash inside the string
-             ((= (char-after curpos) ?\\)
-              (c-put-char-property curpos 'syntax-table '(2)) ; (1) = 
punctuation, (2) = word
-              ;;(message (format "set-s-t: backslash word pos(%d) chr(%c)" 
curpos (char-after curpos)))
-              )
-
-             ;; doubled double-quote
-             ((and
-               (= (char-after curpos) ?\")
-               (= (char-after (+ 1 curpos)) ?\"))
-              (c-put-char-property curpos 'syntax-table '(2)) ; (1) = 
punctuation, (2) = word
-              (c-put-char-property (+ 1 curpos) 'syntax-table '(2)) ; (1) = 
punctuation
-              ;;(message (format "set-s-t: double doublequote pos(%d) chr(%c)" 
curpos (char-after curpos)))
-              (setq curpos (+ curpos 1))
-              )
-
-             ;; a single double-quote, which should be a string terminator
-             ((= (char-after curpos) ?\")
-              (c-put-char-property curpos 'syntax-table '(7)) ; (7) = string 
quote
-              ;;(message (format "set-s-t: close quote pos(%d) chr(%c)" curpos 
(char-after curpos)))
-              ;;go no further
-              (setq state (+ 1 state)))
-
-             ;; everything else
-             (t
-              ;;(message (format "set-s-t: none pos(%d) chr(%c)" curpos 
(char-after curpos)))
-              nil))))
-          ;; next char
-          (setq curpos (+ curpos 1))))))
-
-
-
-(defun csharp-end-of-verbatim-literal-string (&optional lim)
-  "Moves to and returns the position of the end quote of the verbatim literal
-string.  When calling, point should be on the @ of the verblit string.
-If it is not, then no movement is performed and `point' is returned.
-
-This function ignores text properties. In fact it is the
-underlying scanner used to set the text properties in a C# buffer.
-"
-
-  (csharp-log 3 "end-of-vlit-string: point(%d) c(%c)" (point) (char-after))
-
-  (let (curpos
-        (max (or lim (point-max))))
-
-    (if (not (looking-at "@\""))
-        (point)
-      (forward-char 2) ;; pass up the @ sign and first quote
-      (setq curpos (point))
-
-      ;; Within a verbatim literal string, a doubled double-quote
-      ;; escapes the double-quote."
-      (while (and                                  ;; process characters...
-              (or                                  ;; while...
-               (not (eq (char-after curpos) ?\"))  ;; it's not a quote
-               (eq (char-after (+ curpos 1)) ?\")) ;; or, its a double 
(double) quote
-              (< curpos max))                      ;; and we're not done yet
-
-        (cond
-         ((and (eq (char-after curpos) ?\")        ;; it's a double-quote.
-               (eq (char-after (+ curpos 1)) ?\"))
-          (setq curpos (+ 2 curpos)))              ;; Skip 2
-         (t                                        ;; anything else
-          (setq curpos (+ 1 curpos)))))            ;; skip fwd 1
-      curpos)))
-
-
-
-
-(defun csharp-scan-for-verbatim-literals-and-set-props (&optional beg end)
-  "Scans the buffer, between BEG and END, for verbatim literal
-strings, and sets override text properties on each string to
-allow proper syntax highlighting, indenting, and cursor movement.
-
-BEG and END define the limits of the scan.  When nil, they
-default to `point-min' and `point-max' respectively.
-
-Setting text properties generally causes the buffer to be marked
-as modified, but this fn suppresses that via the
-`c-buffer-save-state' macro, for any changes in text properties
-that it makes.  This fn also ignores the read-only setting on a
-buffer, using the same macro.
-
-This fn is called when a csharp-mode buffer is loaded, with BEG
-and END set to nil, to do a full scan.  It is also called on
-every buffer change, with the BEG and END set to the values for
-the change.
-
-The return value is nil if the buffer was not a csharp-mode
-buffer. Otherwise it is the last cursor position examined by the
-scan.
-"
-
-  (if (not (c-major-mode-is 'csharp-mode)) ;; don't scan if not csharp mode
-      nil
-    (save-excursion
-      (c-save-buffer-state
-          ((curpos (or beg (point-min)))
-           (lastpos (or end (point-max)))
-           (state 0) (start 0) (cycle 0)
-           literal eos limits)
-
-        (csharp-log 3 "verblit scan")
-        (goto-char curpos)
-
-        (while (and (< curpos lastpos) (< cycle 10000))
-          (cond
-
-           ;; Case 1: current char is a @ sign
-           ;; --------------------------------------------
-           ;; Check to see if it demarks the beginning of a verblit
-           ;; string.
-           ((= ?@ (char-after curpos))
-
-            ;; are we in a comment?   a string?  Maybe the @ is a prefix
-            ;; to allow the use of a reserved word as a symbol. Let's find out.
-
-            ;; not sure why I need both of the following.
-            (syntax-ppss-flush-cache 1)
-            (parse-partial-sexp 1 curpos)
-            (goto-char curpos)
-            (setq literal (csharp-in-literal))
-            (cond
-
-             ;; Case 1.A: it's a @ within a string.
-             ;; --------------------------------------------
-             ;; This should never happen, because this scanner hops over 
strings.
-             ;; But it might happen if the scan starts at an odd place.
-             ((eq literal 'string) nil)
-
-             ;; Case 1.B: The @ is within a comment.  Hop over it.
-             ((and (memq literal '(c c++))
-                   ;; This is a kludge for XEmacs where we use
-                   ;; `buffer-syntactic-context', which doesn't correctly
-                   ;; recognize "\*/" to end a block comment.
-                   ;; `parse-partial-sexp' which is used by
-                   ;; `c-literal-limits' will however do that in most
-                   ;; versions, which results in that we get nil from
-                   ;; `c-literal-limits' even when `c-in-literal' claims
-                   ;; we're inside a comment.
-                   ;;(setq limits (c-literal-limits start)))
-                   (setq limits (c-literal-limits)))
-
-              ;; advance to the end of the comment
-              (if limits
-                  (progn
-                    (csharp-log 4 "scan: jump end comment A (%d)" (cdr limits))
-                    (setq curpos (cdr limits)))))
-
-
-             ;; Case 1.B: curpos is at least 2 chars before the last
-             ;; position to examine, and, the following char is a
-             ;; double-quote (ASCII 34).
-             ;; --------------------------------------------
-             ;; This looks like the beginning of a verbatim string
-             ;; literal.
-             ((and (< (+ 2 curpos) lastpos)
-                   (= ?\" (char-after (+ 1 curpos))))
-
-              (setq eos (csharp-end-of-verbatim-literal-string))
-              ;; set override syntax properties on the verblit string
-              (csharp-set-vliteral-syntax-table-properties curpos eos)
-
-              (csharp-log 4 "scan: jump end verblit string (%d)" eos)
-              (setq curpos eos))))
-
-
-           ;; Case 2: current char is a double-quote.
-           ;; --------------------------------------------
-           ;; If this is a string, we hop over it, on the assumption that
-           ;; this scanner need not bother with regular literal strings, which
-           ;; get the proper syntax with the generic approach.
-           ;; If in a comment, hop over the comment.
-           ((= ?\" (char-after curpos))
-            (goto-char curpos)
-            (setq literal (c-in-literal))
-            (cond
-
-             ;; Case 2.A: a quote within a string
-             ;; --------------------------------------------
-             ;; This shouldn't happen, because we hop over strings.
-             ;; But it might.
-             ((eq literal 'string) nil)
-
-             ;; Case 2.B: a quote within a comment
-             ;; --------------------------------------------
-             ((and (memq literal '(c c++))
-                   ;; This is a kludge for XEmacs where we use
-                   ;; `buffer-syntactic-context', which doesn't correctly
-                   ;; recognize "\*/" to end a block comment.
-                   ;; `parse-partial-sexp' which is used by
-                   ;; `c-literal-limits' will however do that in most
-                   ;; versions, which results in that we get nil from
-                   ;; `c-literal-limits' even when `c-in-literal' claims
-                   ;; we're inside a comment.
-                   ;;(setq limits (c-literal-limits start)))
-                   (setq limits (c-literal-limits)))
-
-              ;; advance to the end of the comment
-              (if limits
-                  (progn
-                    (setq curpos (cdr limits))
-                    (csharp-log 3 "scan: jump end comment B (%s)" curpos))))
-
-
-             ;; Case 2.C: Not in a comment, and not in a string.
-             ;; --------------------------------------------
-             ;; This is the beginning of a literal (but not verbatim) string.
-             (t
-              (forward-char 1) ;; pass up the quote
-              (if (consp (setq limits (c-literal-limits)))
-                  (progn
-                    (csharp-log 4 "scan: jump end literal (%d)" (cdr limits))
-                    (setq curpos (cdr limits))))))))
-
-          (setq cycle (+ 1 cycle))
-          (setq curpos (+ 1 curpos))
-          (c-safe (goto-char curpos)))))))
-
-
-
-(defun csharp--before-font-lock (beg end old-len)
-  "Adjust`syntax-table' properties on the region affected by the change
-in a csharp-mode buffer.
-
-This function is the C# value for `c-before-font-lock-function'.
-It intended to be called only by the cc-mode runtime.
-
-It prepares the buffer for font locking, hence must get called
-before `font-lock-after-change-function'.
-
-It does hidden buffer changes.
-
-BEG, END and OLD-LEN have the same meaning here as for any
-after-change function.
-
-Point is undefined both before and after this function call.
-The return value is meaningless, and is ignored by cc-mode.
-"
-  (csharp-log 2 "before font lock %d %d %d %d" beg end old-len (point))
-  (let ((start-scan (progn
-                      ;; is this right?  I think
-                      (c-beginning-of-statement 1)
-                      (point))))
-    (csharp-scan-for-verbatim-literals-and-set-props start-scan end)))
-
-
-
-(c-lang-defconst c-before-font-lock-function
-  csharp 'csharp--before-font-lock)
-
-;; ==================================================================
-;; end of c# fontification extensions
-;; ==================================================================
-
-
-
-
-
 ;; ==================================================================
 ;; C#-specific optimizations of cc-mode funcs
 ;; ==================================================================
@@ -4324,11 +3944,6 @@ Key bindings:
   ;; strings accordingly.
   (set (make-local-variable 'parse-sexp-lookup-properties) t)
 
-  ;; scan the entire buffer for verblit strings
-  ;; This will happen on font; it's necessary only
-  ;; if font-lock is disabled. But it won't hurt.
-  (csharp-scan-for-verbatim-literals-and-set-props nil nil)
-
   ;; Allow fill-paragraph to work on xml code doc
   ;; This setting gets overwritten quietly by c-run-mode-hooks,
   ;; so I put it afterwards to make it stick.



reply via email to

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