From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: :regexp to abbrev table Date: Tue, 20 Apr 2010 11:22:47 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1271776999 12236 80.91.229.12 (20 Apr 2010 15:23:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 20 Apr 2010 15:23:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Leo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 20 17:23:17 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O4FIA-0000G2-0O for ged-emacs-devel@m.gmane.org; Tue, 20 Apr 2010 17:23:14 +0200 Original-Received: from localhost ([127.0.0.1]:48329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4FI9-0001Ae-7u for ged-emacs-devel@m.gmane.org; Tue, 20 Apr 2010 11:23:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4FI4-0001AQ-0r for emacs-devel@gnu.org; Tue, 20 Apr 2010 11:23:08 -0400 Original-Received: from [140.186.70.92] (port=43166 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4FI2-00019h-Lh for emacs-devel@gnu.org; Tue, 20 Apr 2010 11:23:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4FI0-0004pF-UT for emacs-devel@gnu.org; Tue, 20 Apr 2010 11:23:06 -0400 Original-Received: from tomts16.bellnexxia.net ([209.226.175.4]:51864 helo=tomts16-srv.bellnexxia.net) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4FI0-0004ot-Ky for emacs-devel@gnu.org; Tue, 20 Apr 2010 11:23:04 -0400 Original-Received: from toip3.srvr.bell.ca ([209.226.175.86]) by tomts16-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20100420152250.ODZZ5228.tomts16-srv.bellnexxia.net@toip3.srvr.bell.ca> for ; Tue, 20 Apr 2010 11:22:50 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAItezUtGN5OL/2dsb2JhbACcAHK9V4JtCIIaBA Original-Received: from bas1-montreal42-1178047371.dsl.bell.ca (HELO ceviche.home) ([70.55.147.139]) by toip3.srvr.bell.ca with ESMTP; 20 Apr 2010 11:15:03 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 246FB660D2; Tue, 20 Apr 2010 11:22:47 -0400 (EDT) In-Reply-To: (Leo's message of "Tue, 20 Apr 2010 14:37:37 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Solaris 8 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:123918 Archived-At: >>> 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)) " ")))))) + (lambda (str) (if (fboundp (intern-soft str)) " "))))))) ;; arch-tag: aa7fa8a4-2e6f-4e9b-9cd9-fef06340e67e ;;; lisp.el ends here