aboutsummaryrefslogtreecommitdiffhomepage
path: root/coq/coq.el
diff options
context:
space:
mode:
authorGravatar Pierre Courtieu <Pierre.Courtieu@cnam.fr>2016-05-02 14:06:51 +0200
committerGravatar Pierre Courtieu <Pierre.Courtieu@cnam.fr>2016-05-02 14:06:51 +0200
commit69554c0916c0279bde6b795cb79f87b55069b25f (patch)
treeedb268da72f92a38f019fbb49cd109eab464e401 /coq/coq.el
parentdbfe0a4f3b7be8f18ff89f5a544cb9d9ef891b70 (diff)
Fixing detection of symbol at point.
Quote at start of a word should not be considered part of the word. Other characters than ' or _ are punctuation.
Diffstat (limited to 'coq/coq.el')
-rw-r--r--coq/coq.el15
1 files changed, 12 insertions, 3 deletions
diff --git a/coq/coq.el b/coq/coq.el
index 6c745604..f04c3dfe 100644
--- a/coq/coq.el
+++ b/coq/coq.el
@@ -816,6 +816,16 @@ Return nil if S is nil."
(substring s 0 (- (length s) 1))
s))
+(defun coq-remove-heading-quote (s)
+ "Return the string S without its heading \"\'\" if any.
+Return nil if S is nil."
+ (if (and s (string-match "\\`'" s))
+ (substring s 1 (length s))
+ s))
+
+(defun coq-clean-id-at-point (s)
+ (coq-remove-heading-quote (coq-remove-trailing-dot s)))
+
(defun coq-is-symbol-or-punct (c)
"Return non nil if character C is a punctuation or a symbol constituent.
If C is nil, return nil."
@@ -860,9 +870,8 @@ Support dot.notation.of.modules."
(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)))
- (not (coq-string-starts-with-symbol symbclean)))
+ (symbclean (when symb (coq-clean-id-at-point (symbol-name symb)))))
+ (when (and symb (not (zerop (length symbclean))))
symbclean))))