unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Leo <sdl.web@googlemail.com>
Cc: emacs-devel@gnu.org
Subject: Re: :regexp to abbrev table
Date: Tue, 20 Apr 2010 11:22:47 -0400	[thread overview]
Message-ID: <jwvd3xutaym.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <n2s20a0c1021004200637na7930a3cj8419562c7ec0133f@mail.gmail.com> (Leo's message of "Tue, 20 Apr 2010 14:37:37 +0100")

>>> 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	other threads:[~2010-04-20 15:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16 10:06 :regexp to abbrev table Leo
2010-04-19  6:29 ` Stefan Monnier
2010-04-19 18:26   ` Leo
     [not found]     ` <jwvljcj8ee1.fsf-monnier+emacs@gnu.org>
2010-04-20 13:37       ` Leo
2010-04-20 15:22         ` Stefan Monnier [this message]
2010-04-20 16:32           ` Leo
2010-04-20 18:39             ` Leo
2010-04-21  4:26               ` Stefan Monnier
2010-04-21  6:37                 ` Leo
     [not found]                   ` <jwv4oj46gfy.fsf-monnier+emacs@gnu.org>
2010-04-21 15:09                     ` Leo
     [not found]                       ` <jwvaasw4s7w.fsf-monnier+emacs@gnu.org>
2010-04-21 19:25                         ` Leo
2010-04-23  3:23                           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvd3xutaym.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=sdl.web@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).