emacs-devel
[Top][All Lists]
Advanced

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

Re: :regexp to abbrev table


From: Stefan Monnier
Subject: Re: :regexp to abbrev table
Date: Tue, 20 Apr 2010 11:22:47 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>>> Is it possible for you to provide an actual regexp to find abbrevs that
>>> contains word, symbol or \?
>> I'd start with "\\(?:^\\|[^[:word:]\\]\\)\\([[:word:]\\]+\\)[ \t]*".
>> For symbols, I recommend you list the chars you want in the above regexp
>> rather than rely on the `symbol' char syntax.
> Many thanks for this. I will bear this in mind when writing the abbrev
> completion code. Since TAB can be configured to perform two roles:
> indentation and completion through (setq tab-always-indent 'complete).
> Completion in the middle of a 'word' often lead to undesirable change
> of the text in buffer. For example: (emacs-lis|p-mode) where | is the
> cursor. TAB will change the text to (emacs-lisp-p-mode).

This is indeed a problem we need to fix: it should take the tail into
account, just as is done in the minibuffer.  Try the patch below.
Of course, it will not necessarily always solve the problem that "I just
wanted to reindent and it started to complete and annoyed me".

> The same situation applies to abbrevs and the :regexp doesn't make it
> easy to find the 'end' boundary.

I don't understand how it relates.


        Stefan


=== modified file 'lisp/emacs-lisp/lisp.el'
--- lisp/emacs-lisp/lisp.el     2010-01-13 08:35:10 +0000
+++ lisp/emacs-lisp/lisp.el     2010-04-20 15:20:36 +0000
@@ -631,12 +631,11 @@
 
 (defun lisp-completion-at-point (&optional predicate)
   ;; FIXME: the `end' could be after point?
-  (let* ((end (point))
+  (let* ((pos (point))
          (beg (with-syntax-table emacs-lisp-mode-syntax-table
                 (save-excursion
                   (backward-sexp 1)
-                  (while (= (char-syntax (following-char)) ?\')
-                    (forward-char 1))
+                  (skip-syntax-forward "'")
                   (point))))
          (predicate
           (or predicate
@@ -656,12 +655,21 @@
                       ;; Maybe a `let' varlist or something.
                       nil
                     ;; Else, we assume that a function name is expected.
-                    'fboundp))))))
+                    'fboundp)))))
+         (end
+          (unless (or (eq beg (point-max))
+                      (member (char-syntax (char-after beg)) '(?\( ?\))))
+            (save-excursion
+              (goto-char beg)
+              (forward-sexp 1)
+              (when (>= (point) pos)
+                (point))))))
+    (when end
     (list beg end obarray
           :predicate predicate
           :annotate-function
             (unless (eq predicate 'fboundp)
-              (lambda (str) (if (fboundp (intern-soft str)) " <f>"))))))
+              (lambda (str) (if (fboundp (intern-soft str)) " <f>")))))))
 
 ;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e
 ;;; lisp.el ends here





reply via email to

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