diff options
author | 2015-02-23 16:20:57 +0000 | |
---|---|---|
committer | 2015-02-23 16:20:57 +0000 | |
commit | 611fbfb2fc93f240c4bb2a8dbbbcfd0921145ef5 (patch) | |
tree | 1867b7f052e6411bc73cdb68600138c8faf88153 /coq | |
parent | f735ddcd7472cdb0c9093e803db57a8828f59933 (diff) |
Fixed a bug in syntax table making fontlock and indentation fail.
After some command detecting things at point, the indentation was broken.
Diffstat (limited to 'coq')
-rw-r--r-- | coq/coq-syntax.el | 10 | ||||
-rw-r--r-- | coq/coq.el | 23 |
2 files changed, 21 insertions, 12 deletions
diff --git a/coq/coq-syntax.el b/coq/coq-syntax.el index 7848bcac..a4e11ba1 100644 --- a/coq/coq-syntax.el +++ b/coq/coq-syntax.el @@ -1096,6 +1096,16 @@ It is used: (modify-syntax-entry ?\( "()1") (modify-syntax-entry ?\) ")(4")) +;; use this to evaluate code with "." being consisdered a symbol +;; constituent (better behavior for thing-at and maybe font-lock too, +;; for indentation we use ad hoc smie lexers). +(defmacro coq-with-altered-syntax-table (&rest code) + (let ((res (make-symbol "res"))) + `(unwind-protect + (progn (modify-syntax-entry ?\. "_") + (let ((,res (progn ,@code))) + (modify-syntax-entry ?\. ".") + ,res))))) (defconst coq-generic-expression (mapcar (lambda (kw) @@ -740,22 +740,22 @@ Return nil if S is nil." (defun coq-notation-at-position (pos) "Return the notation at current point. Support dot.notation.of.modules." - (modify-syntax-entry ?\. "w") ; temporary for dot notation - (when (or (coq-grab-punctuation-left pos) (coq-grab-punctuation-right pos)) - (concat (coq-grab-punctuation-left pos) (coq-grab-punctuation-right pos)))) + (coq-with-altered-syntax-table + (when (or (coq-grab-punctuation-left pos) (coq-grab-punctuation-right pos)) + (concat (coq-grab-punctuation-left pos) + (coq-grab-punctuation-right pos))))) ;; remove trailing dot if any. (defun coq-id-at-point () "Return the identifier at current point. Support dot.notation.of.modules." - (modify-syntax-entry ?\. "w") ; temporary for dot notation - (let* ((symb (cond - ((fboundp 'symbol-near-point) (symbol-near-point)) - ((fboundp 'symbol-at-point) (symbol-at-point)))) - (symbclean (when symb (coq-remove-trailing-dot (symbol-name symb))))) - (modify-syntax-entry ?\. ".") ; go back to ususal syntax - (when (and symb (not (zerop (length symbclean)))) symbclean))) + (coq-with-altered-syntax-table + (let* ((symb (cond + ((fboundp 'symbol-near-point) (symbol-near-point)) + ((fboundp 'symbol-at-point) (symbol-at-point)))) + (symbclean (when symb (coq-remove-trailing-dot (symbol-name symb))))) + (when (and symb (not (zerop (length symbclean)))) symbclean)))) (defun coq-id-or-notation-at-point () (or (coq-id-at-point) (coq-notation-at-position (point)))) @@ -788,8 +788,7 @@ If DONTGUESS is non nil, propose a default value as follows: If region is active, propose its containt as default value. Otherwise propose identifier at point if any." - (let* ( - (guess + (let* ((guess (cond (dontguess nil) ((use-region-p) |