From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Aur=C3=A9lien_Aptel?= Newsgroups: gmane.emacs.help Subject: Using punctuation in abbrev Date: Sat, 1 Jun 2013 19:41:55 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1370108529 21504 80.91.229.3 (1 Jun 2013 17:42:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 1 Jun 2013 17:42:09 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 01 19:42:09 2013 Return-path: Envelope-to: geh-help-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 1Uipoe-00033t-Jw for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Jun 2013 19:42:08 +0200 Original-Received: from localhost ([::1]:49548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uipod-00009Z-Hm for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Jun 2013 13:42:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UipoU-00009U-Gq for help-gnu-emacs@gnu.org; Sat, 01 Jun 2013 13:41:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UipoT-0004ql-KZ for help-gnu-emacs@gnu.org; Sat, 01 Jun 2013 13:41:58 -0400 Original-Received: from mail-la0-x234.google.com ([2a00:1450:4010:c03::234]:58508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UipoT-0004qc-E2 for help-gnu-emacs@gnu.org; Sat, 01 Jun 2013 13:41:57 -0400 Original-Received: by mail-la0-f52.google.com with SMTP id fo13so2318706lab.11 for ; Sat, 01 Jun 2013 10:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=o8M2Ah4v3xRS+CkWqjv3OTCAUxx2R8kt88XLSlQxMo0=; b=ieF3D8Qb7PCrhf8zgj3I4GT8QZAzcs64TMO/9sfXKzVe+NT54KKDVhKDsVpdIaCVsb c+ZAGMRzCj7/Tq294m1iEQ20d212sT2tTIsu9u/8+LAbg55mN+7f+Mi+UB/zEgms3+R0 VhyZJC4TiorfBxyOK+PfxvfbU0SwkMXQfDU4KoOASoC3buuPLuHSE5NHN04i7FvzIUBf MUGuYGxIoYlMS4J5x01mLcXstSnJw3gsEV6tSXXW3JFxaYoKfYi8keCA8FVzE/0pkorA XkdX/QNUBJKyaCzVufJ0HdbGwpWEaUDeEfq2D2zzi6+V+V6loe8SnAemckthr34GPCQ8 mFug== X-Received: by 10.112.188.161 with SMTP id gb1mr8031422lbc.107.1370108515748; Sat, 01 Jun 2013 10:41:55 -0700 (PDT) Original-Received: by 10.114.91.201 with HTTP; Sat, 1 Jun 2013 10:41:55 -0700 (PDT) X-Google-Sender-Auth: -dlJvmo3G6l3WPSiLT2WOpZhupU X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::234 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91216 Archived-At: Hi, I want to substitute $-> with a unicode rightwards arrow (U+2192 =E2=86=92= ). Since abbrev defaults to backward-word to extract the word before point, I've used the :regexp property of an abbrev-table to define what to extract. >From define-abbrev-table documentation: - `:regexp' is a regular expression that specifies how to extract the name of the abbrev before point. The submatch 1 is treated as the potential name of an abbrev. If :regexp is nil, the default behavior uses `backward-word' and `forward-word' to extract the name of the abbrev, which can therefore only be a single word. Here's what I put in my init file: (define-abbrev-table 'global-abbrev-table '( ("$->" "=E2=86=92") ("$=3D>" "=E2=87=92") ("$foo" "X") ) "custom abbrev table" :regexp (rx (or bos bol space) (group (+ (not space))))) (setq save-abbrevs nil) (setq-default abbrev-mode t) But only the $foo substitution works and I can't figure out why. The regex seems to be correct: (let ((rx (rx (or bos bol space) (group (+ (not space))))) (slist '(" $->" "\n$=3D>" " $foo"))) (mapcar (lambda (s) (string-match-p rx s)) slist)) =3D> (0 0 0)