From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Keith Ponting" Newsgroups: gmane.emacs.bugs Subject: bug#2205: My fix does not quite work Date: Thu, 5 Feb 2009 08:12:29 -0500 Message-ID: <0368DB7855FE094FBFF313BE6BC5A810D485BA@BE02.exg3.exghost.com> Reply-To: Keith Ponting , 2205@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C98793.18C8942C" X-Trace: ger.gmane.org 1233847134 31608 80.91.229.12 (5 Feb 2009 15:18:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Feb 2009 15:18:54 +0000 (UTC) To: <2205@emacsbugs.donarmstrong.com> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Feb 05 16:19:59 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LV617-0002Yo-FT for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 Feb 2009 16:19:50 +0100 Original-Received: from localhost ([127.0.0.1]:51882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LV5zo-0005d8-7l for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 Feb 2009 10:18:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LV4Ck-0007m4-2b for bug-gnu-emacs@gnu.org; Thu, 05 Feb 2009 08:23:42 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LV4Cf-0007jP-OV for bug-gnu-emacs@gnu.org; Thu, 05 Feb 2009 08:23:39 -0500 Original-Received: from [199.232.76.173] (port=43136 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LV4Cf-0007jF-CB for bug-gnu-emacs@gnu.org; Thu, 05 Feb 2009 08:23:37 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:59267) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LV4Ce-000652-2C for bug-gnu-emacs@gnu.org; Thu, 05 Feb 2009 08:23:36 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n15DNWcB027077; Thu, 5 Feb 2009 05:23:32 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n15DK4kI026048; Thu, 5 Feb 2009 05:20:04 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: "Keith Ponting" Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 05 Feb 2009 13:20:03 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 2205 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 2205-submit@emacsbugs.donarmstrong.com id=B2205.123383955724718 (code B ref 2205); Thu, 05 Feb 2009 13:20:03 +0000 Original-Received: (at 2205) by emacsbugs.donarmstrong.com; 5 Feb 2009 13:12:37 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from server107.appriver.com (server107k.exghost.com [69.20.106.170]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n15DCY42024712 for <2205@emacsbugs.donarmstrong.com>; Thu, 5 Feb 2009 05:12:35 -0800 Original-Received: by server107.appriver.com (CommuniGate Pro PIPE 5.2.0) with PIPE id 155570510; Thu, 05 Feb 2009 08:12:33 -0500 Original-Received: from [207.97.230.107] (HELO fe09.exg3.exghost.com) by server107.appriver.com (CommuniGate Pro SMTP 5.2.0) with ESMTP id 155570508 for 2205@emacsbugs.donarmstrong.com; Thu, 05 Feb 2009 08:12:30 -0500 Original-Received: from BE02.exg3.exghost.com ([207.97.230.117]) by fe09.exg3.exghost.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 5 Feb 2009 08:10:20 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: My fix does not quite work thread-index: AcmHk2W0DHcNxtNSTgqLyrzAZXeG9Q== X-OriginalArrivalTime: 05 Feb 2009 13:10:20.0177 (UTC) FILETIME=[18BD4810:01C98793] X-Policy: GLOBAL - aurix.com X-Primary: k.ponting@aurix.com X-Note: This Email was scanned by AppRiver SecureTide X-ALLOW: k.ponting@aurix.com ALLOWED X-Virus-Scan: V- X-Note: Spam Tests Failed: X-Country-Path: UNITED STATES->UNITED STATES->UNITED STATES X-Note-Sending-IP: 207.97.230.107 X-Note-Reverse-DNS: fe09.exg3.exghost.com X-Note-WHTLIST: k.ponting@aurix.com X-Note: User Rule Hits: X-Note: Global Rule Hits: 94 95 96 97 101 102 170 X-Note: Mail Class: ALLOWEDSENDER X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Thu, 05 Feb 2009 08:23:39 -0500 X-Mailman-Approved-At: Thu, 05 Feb 2009 10:10:32 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:24971 Archived-At: This is a multi-part message in MIME format. ------_=_NextPart_001_01C98793.18C8942C Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable A small postscript - the save-excursion fix I suggested does not quite work as it leaves point _before_ the inserted terminator not after it. The following rearrangement works around that: =20 (defun perl-electric-terminator (arg) "Insert character and adjust indentation. If at end-of-line, and not in a comment or a quote, correct the's indentation." (interactive "P") (let ((insertpos (point))) (and (not arg) ; decide whether to indent (eolp) (save-excursion (beginning-of-line) (and (not ; eliminate comments quickly (and comment-start-skip (re-search-forward comment-start-skip insertpos t)) ) (or (/=3D last-command-char ?:) ;; Colon is special only after a label .... (looking-at "\\s-*\\(\\w\\|\\s_\\)+$")) (let ((pps (parse-partial-sexp =20 (perl-beginning-of-function) insertpos))) (not (or (nth 3 pps) (nth 4 pps) (nth 5 pps)))))) (progn ; must insert, indent, delete (insert-char last-command-char 1) (save-excursion (perl-indent-line)) (delete-char -1)))) (self-insert-command (prefix-numeric-value arg))) =20 =20 =20 Keith Ponting Aurix Ltd, Malvern WR14 3SZ UK =20 ------_=_NextPart_001_01C98793.18C8942C Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

A small postscript - the save-excursion  fix I suggested does not quite work as it leaves point _before_ the = inserted terminator not after it.

The following rearrangement works around = that:

 

(defun perl-electric-terminator = (arg)

  "Insert character and adjust = indentation.

If at end-of-line, and not in a comment or a quote, = correct the's indentation."

  (interactive "P")

  (let ((insertpos (point)))

    (and (not = arg)           &nb= sp;           &nbs= p;            = ;            ; decide whether to indent

         &= nbsp;       (eolp)

         &= nbsp;       (save-excursion

         &= nbsp;         (beginning-of-line)

         &= nbsp;         (and = (not           &nb= sp;           &nbs= p;            = ;      ; eliminate comments quickly

         &= nbsp;           &n= bsp;           (and comment-start-skip

         &= nbsp;           &n= bsp;          =       (re-search-forward comment-start-skip insertpos t)) )

         &= nbsp;           &n= bsp;          (or (/=3D last-command-char ?:)

         &= nbsp;           &n= bsp;          =     ;; Colon is special only after a label ....

         &= nbsp;           &n= bsp;          =     (looking-at "\\s-*\\(\\w\\|\\s_\\)+$"))

         &= nbsp;           &n= bsp;          (let ((pps (parse-partial-sexp

         &= nbsp;           &n= bsp;           &nb= sp;           &nbs= p;      (perl-beginning-of-function) insertpos)))

         &= nbsp;           &n= bsp;            (not (or (nth 3 pps) (nth 4 pps) (nth 5 pps))))))

         &= nbsp;       (progn =                    &= nbsp;            = ; must insert, indent, delete

         &= nbsp;         (insert-char last-command-char 1)

         &= nbsp;         (save-excursion (perl-indent-line))

         &= nbsp;         (delete-char -1))))

  (self-insert-command (prefix-numeric-value = arg)))

 

 

 

Keith Ponting

Aurix Ltd, Malvern WR14 3SZ  UK

 

------_=_NextPart_001_01C98793.18C8942C--