From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#19400: 24.4.50; `completion-separator-self-insert-command' calls `undefined' with error Date: Fri, 19 Dec 2014 17:48:29 -0500 Message-ID: References: <87a92m11iw.fsf@yahoo.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1419029372 15217 80.91.229.3 (19 Dec 2014 22:49:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Dec 2014 22:49:32 +0000 (UTC) Cc: 19400@debbugs.gnu.org To: Nicolas Richard Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 19 23:49:25 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y26MO-0003Mr-Ex for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 Dec 2014 23:49:24 +0100 Original-Received: from localhost ([::1]:60820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y26MN-0003KQ-9F for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 Dec 2014 17:49:23 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y26MB-0003Jq-37 for bug-gnu-emacs@gnu.org; Fri, 19 Dec 2014 17:49:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y26M2-0006Wg-QE for bug-gnu-emacs@gnu.org; Fri, 19 Dec 2014 17:49:11 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y26M2-0006WY-O5 for bug-gnu-emacs@gnu.org; Fri, 19 Dec 2014 17:49:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y26M2-0006Ym-C6 for bug-gnu-emacs@gnu.org; Fri, 19 Dec 2014 17:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Dec 2014 22:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19400 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19400-submit@debbugs.gnu.org id=B19400.141902933625204 (code B ref 19400); Fri, 19 Dec 2014 22:49:02 +0000 Original-Received: (at 19400) by debbugs.gnu.org; 19 Dec 2014 22:48:56 +0000 Original-Received: from localhost ([127.0.0.1]:51957 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y26Lv-0006YQ-6A for submit@debbugs.gnu.org; Fri, 19 Dec 2014 17:48:55 -0500 Original-Received: from mercure.iro.umontreal.ca ([132.204.24.67]:45038) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y26Ls-0006YG-VD for 19400@debbugs.gnu.org; Fri, 19 Dec 2014 17:48:53 -0500 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 57BFC851B6; Fri, 19 Dec 2014 17:48:52 -0500 (EST) Original-Received: from lechon.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 9446F1E5B8B; Fri, 19 Dec 2014 17:48:29 -0500 (EST) Original-Received: by lechon.iro.umontreal.ca (Postfix, from userid 20848) id 71138B40DF; Fri, 19 Dec 2014 17:48:29 -0500 (EST) In-Reply-To: <87a92m11iw.fsf@yahoo.fr> (Nicolas Richard's message of "Wed, 17 Dec 2014 21:09:43 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82, MC_TSTLAST 0.00) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97583 Archived-At: > emacs -Q -f dynamic-completion-mode [ Yuck! completion.el is one of the packages which does not following the prefix convention *at all*. ] > Instead of "^ is undefined", I get > "completion-separator-self-insert-command: Wrong number of arguments: (0 > . 0), 1" Does the patch below fix this problem (I'm pretty sure it does), and more importantly, does it seem to preserve the expected behavior? Stefan diff --git a/lisp/completion.el b/lisp/completion.el index d2d94e7..3e8b6aa 100644 --- a/lisp/completion.el +++ b/lisp/completion.el @@ -2156,26 +2156,27 @@ Patched to remove the most recent completion." ;; to work) ;; All common separators (eg. space "(" ")" """) characters go through a -;; function to add new words to the list of words to complete from: -;; COMPLETION-SEPARATOR-SELF-INSERT-COMMAND (arg). +;; function to add new words to the list of words to complete from. ;; If the character before this was an alpha-numeric then this adds the ;; symbol before point to the completion list (using ADD-COMPLETION). -(defun completion-separator-self-insert-command (arg) - (interactive "p") - (if (command-remapping 'self-insert-command) - (funcall (command-remapping 'self-insert-command) arg) - (use-completion-before-separator) - (self-insert-command arg))) - -(defun completion-separator-self-insert-autofilling (arg) - (interactive "p") - (if (command-remapping 'self-insert-command) - (funcall (command-remapping 'self-insert-command) arg) - (use-completion-before-separator) - (self-insert-command arg) - (and auto-fill-function - (funcall auto-fill-function)))) +(defvar completion-separator-chars + (append " !%^&()=`|{}[];\\'#,?" + ;; We include period and colon even though they are symbol + ;; chars because : + ;; - in text we want to pick up the last word in a sentence. + ;; - in C pointer refs. we want to pick up the first symbol + ;; - it won't make a difference for lisp mode (package names + ;; are short) + ".:")) + +(defun completion--post-self-insert () + (when (memq last-command-event completion-separator-chars) + (let ((after-pos (electric--after-char-pos))) + (when after-pos + (save-excursion + (goto-char (1- after-pos)) + (use-completion-before-separator)))))) ;;----------------------------------------------- ;; Wrapping Macro @@ -2244,9 +2245,8 @@ TYPE is the type of the wrapper to be added. Can be :before or :under." (completion-def-wrapper 'electric-c-semi :separator) (defun completion-c-mode-hook () (setq completion-syntax-table completion-c-syntax-table) - (local-set-key "+" 'completion-separator-self-insert-command) - (local-set-key "*" 'completion-separator-self-insert-command) - (local-set-key "/" 'completion-separator-self-insert-command)) + (setq-local completion-separator-chars + (append "+*/" completion-separator-chars))) ;; FORTRAN mode diffs. (these are defined when fortran is called) @@ -2259,10 +2259,8 @@ TYPE is the type of the wrapper to be added. Can be :before or :under." (defun completion-setup-fortran-mode () (setq completion-syntax-table completion-fortran-syntax-table) - (local-set-key "+" 'completion-separator-self-insert-command) - (local-set-key "-" 'completion-separator-self-insert-command) - (local-set-key "*" 'completion-separator-self-insert-command) - (local-set-key "/" 'completion-separator-self-insert-command)) + (setq-local completion-separator-chars + (append "+-*/" completion-separator-chars))) ;; Enable completion mode. @@ -2281,15 +2279,16 @@ if ARG is omitted or nil." ;; This is always good, not specific to dynamic-completion-mode. (define-key function-key-map [C-return] [?\C-\r]) - (dolist (x '((find-file-hook . completion-find-file-hook) - (pre-command-hook . completion-before-command) + (dolist (x `((find-file-hook . ,#'completion-find-file-hook) + (pre-command-hook . ,#'completion-before-command) ;; Save completions when killing Emacs. - (kill-emacs-hook . kill-emacs-save-completions) - + (kill-emacs-hook . ,#'kill-emacs-save-completions) + (post-self-insert-hook . ,#'completion--post-self-insert) + ;; Install the appropriate mode tables. - (lisp-mode-hook . completion-lisp-mode-hook) - (c-mode-hook . completion-c-mode-hook) - (fortran-mode-hook . completion-setup-fortran-mode))) + (lisp-mode-hook . ,#'completion-lisp-mode-hook) + (c-mode-hook . ,#'completion-c-mode-hook) + (fortran-mode-hook . ,#'completion-setup-fortran-mode))) (if dynamic-completion-mode (add-hook (car x) (cdr x)) (remove-hook (car x) (cdr x)))) @@ -2315,44 +2314,7 @@ if ARG is omitted or nil." ;; cumb ;; Patches to standard keymaps insert completions - ([remap kill-region] . completion-kill-region) - - ;; Separators - ;; We've used the completion syntax table given as a guide. - ;; - ;; Global separator chars. - ;; We left out because there are too many special - ;; cases for it. Also, in normal coding it's rarely typed - ;; after a word. - (" " . completion-separator-self-insert-autofilling) - ("!" . completion-separator-self-insert-command) - ("%" . completion-separator-self-insert-command) - ("^" . completion-separator-self-insert-command) - ("&" . completion-separator-self-insert-command) - ("(" . completion-separator-self-insert-command) - (")" . completion-separator-self-insert-command) - ("=" . completion-separator-self-insert-command) - ("`" . completion-separator-self-insert-command) - ("|" . completion-separator-self-insert-command) - ("{" . completion-separator-self-insert-command) - ("}" . completion-separator-self-insert-command) - ("[" . completion-separator-self-insert-command) - ("]" . completion-separator-self-insert-command) - (";" . completion-separator-self-insert-command) - ("\"". completion-separator-self-insert-command) - ("'" . completion-separator-self-insert-command) - ("#" . completion-separator-self-insert-command) - ("," . completion-separator-self-insert-command) - ("?" . completion-separator-self-insert-command) - - ;; We include period and colon even though they are symbol - ;; chars because : - ;; - in text we want to pick up the last word in a sentence. - ;; - in C pointer refs. we want to pick up the first symbol - ;; - it won't make a difference for lisp mode (package names - ;; are short) - ("." . completion-separator-self-insert-command) - (":" . completion-separator-self-insert-command))) + ([remap kill-region] . completion-kill-region))) (push (cons (car binding) (lookup-key global-map (car binding))) completion-saved-bindings) (global-set-key (car binding) (cdr binding)))