Function: csharp-guess-basic-syntax

csharp-guess-basic-syntax is a byte-compiled function defined in csharp-mode.el.gz.

Signature

(csharp-guess-basic-syntax ORIG-FUN &rest ARGS)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/csharp-mode.el.gz
(defun csharp-guess-basic-syntax (orig-fun &rest args)
  (cond
   (;; enum
    (save-excursion
      (goto-char (c-point 'boi))
      (and
       (eq (char-after) ?\{)
       (save-excursion
         (goto-char (c-point 'iopl))
         (looking-at ".*enum.*"))))
    `((class-open ,(c-point 'iopl))))
   (;; Attributes
    (save-excursion
      (goto-char (c-point 'iopl))
      (and
       (eq (save-excursion
             (skip-chars-forward " \t\n")
             (char-after))
           ?\[)
       (save-excursion
         (c-go-list-forward)
         (and (eq (char-before) ?\])
              (not (eq (char-after) ?\;))))))
    `((annotation-top-cont ,(c-point 'iopl))))
   ((and
     ;; Heuristics to find object initializers
     (save-excursion
       ;; Next non-whitespace character should be '{'
       (goto-char (c-point 'boi))
       (unless (eq (char-after) ?{)
         (ignore-errors (backward-up-list 1 t t)))
       (save-excursion
         ;; 'new' should be part of the line, but should not trigger if
         ;; statement has already ended, like for 'var x = new X();'.
         ;; Also, deal with the possible end of line obscured by a
         ;; trailing comment.
         (goto-char (c-point 'iopl))
         (when (looking-at-p ".*new.*")
           (if (re-search-forward ";" (pos-eol) t 1)
               ;; If the ';' is inside a comment, the statement hasn't
               ;; likely ended, so we should accept as object init.
               ;; Example:
               ;; var x = new         // This should return true ;
               ;; var x = new();      // This should return false ;
               (nth 4 (syntax-ppss (point)))
             t))))
     ;; Line should not already be terminated
     (save-excursion
       (goto-char (c-point 'eopl))
       (or (not (eq (char-before) ?\;))
           (not (eq (char-before) ?\{)))))
    (cond
     ((save-excursion
        ;; if we have a hanging brace on line before
        (goto-char (c-point 'eopl))
        (eq (char-before) ?\{))
      `((brace-list-intro ,(c-point 'iopl))))
     ((save-excursion
        ;; if we have a hanging brace on line before
        (goto-char (c-point 'boi))
        (and (eq (char-after) ?\})
             `((brace-list-close ,(save-excursion
                                    (backward-up-list 1 t t)
                                    (point)))))))
     (t
      `((block-open) (statement ,(c-point 'iopl))))))
   (t
    (apply orig-fun args))))