From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.devel Subject: Proposal: make up-list escape strings Date: Tue, 08 Apr 2014 16:14:58 -0700 Message-ID: <534482F2.6010504@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wSil80VsBxRwpf2v3AbOdGrStJBEShLrh" X-Trace: ger.gmane.org 1396998921 28465 80.91.229.3 (8 Apr 2014 23:15:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Apr 2014 23:15:21 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Apr 09 01:15:15 2014 Return-path: Envelope-to: ged-emacs-devel@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 1WXfEX-0003j2-FE for ged-emacs-devel@m.gmane.org; Wed, 09 Apr 2014 01:15:13 +0200 Original-Received: from localhost ([::1]:43473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXfEX-0001IB-10 for ged-emacs-devel@m.gmane.org; Tue, 08 Apr 2014 19:15:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXfET-0001Gl-77 for emacs-devel@gnu.org; Tue, 08 Apr 2014 19:15:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXfER-0005Vk-RD for emacs-devel@gnu.org; Tue, 08 Apr 2014 19:15:09 -0400 Original-Received: from dancol.org ([2600:3c01::f03c:91ff:fedf:adf3]:36590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXfER-0005D0-EH for emacs-devel@gnu.org; Tue, 08 Apr 2014 19:15:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:Subject:To:MIME-Version:From:Date:Message-ID; bh=mtIcylrMzzUZ+3hnARfnNTfP1u1qO1aJO6Hq2A/44nc=; b=pdympSDsc09P2yVDh2OC/ODyvyK1jscQU+gAKc3rWW4Mx0Z1oyYnrb87z8Ltd2wnIy5sKrxEKek7pmcf/+HQ1iCVJAeDv4Qm1M9excn5xtPP5+VRKJlsM5iyycLze02mpHysP9omj/uo/2XSGFvdtYB3bh5PUOz3x86q1/Cqlspw1bjS59yojBlrwo6MVh8iouE7bY+8eTrGuyzUypfq1jKbOWmNUwrwtRk9OM69/9aLrGnTcn9Ry9uXyXq+r6A3nuzmilxqKxM30doIJCaQKbJEofHjhzgVhAMxlQnCrEZvdHOoEtzdg3N0phWF1+BmyygKlvQKcvdwp7zgygf+ug==; Original-Received: from [2601:8:b200:551::2b1] by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1WXfEJ-00046O-A2 for emacs-devel@gnu.org; Tue, 08 Apr 2014 16:14:59 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 X-Enigmail-Version: 1.6 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2600:3c01::f03c:91ff:fedf:adf3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:171352 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --wSil80VsBxRwpf2v3AbOdGrStJBEShLrh Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Here's a small patch that makes backward-up-list and up-list escape strings as well as explicit lists. This behavior is active only when these functions are called interactively or when lisp explicitly asks for this behavior, so the change shouldn't pose a compatibility risk. Backing out of strings is generally a useful thing to do when you want to operate on the string as a whole. =3D=3D=3D modified file 'lisp/emacs-lisp/lisp.el' --- lisp/emacs-lisp/lisp.el 2014-02-26 02:31:27 +0000 +++ lisp/emacs-lisp/lisp.el 2014-04-08 23:12:16 +0000 @@ -140,38 +140,58 @@ (goto-char (or (scan-lists (point) inc -1) (buffer-end arg))) (setq arg (- arg inc))))) -(defun backward-up-list (&optional arg) +(defun backward-up-list (&optional arg escape-strings) "Move backward out of one level of parentheses. This command will also work on other parentheses-like expressions defined by the current language mode. With ARG, do this that many times. A negative argument means move forward but still to a less deep spot. -This command assumes point is not in a string or comment." - (interactive "^p") - (up-list (- (or arg 1)))) +This command assumes point is not in a string or comment. +If ESCAPE-STRINGS is non-nil (as it is interactively), treat +encoding strings as sexps." + (interactive "^p\nd") + (up-list (- (or arg 1)) escape-strings)) -(defun up-list (&optional arg) +(defun up-list (&optional arg escape-strings) "Move forward out of one level of parentheses. This command will also work on other parentheses-like expressions defined by the current language mode. With ARG, do this that many times. A negative argument means move backward but still to a less deep spot. -This command assumes point is not in a string or comment." - (interactive "^p") +If ESCAPE-STRINGS is non-nil (as it is interactively), treat +encoding strings as sexps." + (interactive "^p\nd") (or arg (setq arg 1)) (let ((inc (if (> arg 0) 1 -1)) pos) (while (/=3D arg 0) (if (null forward-sexp-function) - (goto-char (or (scan-lists (point) inc 1) (buffer-end arg))) + (condition-case err + (goto-char (or (scan-lists (point) inc 1) (buffer-end arg)= )) + (scan-error + (or (and escape-strings + (let ((syntax (syntax-ppss))) + (and (nth 3 syntax) + (nth 8 syntax)) + (goto-char (nth 8 syntax)) + (when (> arg 0) (forward-sexp)) + t)) + (signal (car err) (cdr err))))) (condition-case err (while (progn (setq pos (point)) (forward-sexp inc) (/=3D (point) pos))) (scan-error (goto-char (nth (if (> arg 0) 3 2) err)))) (if (=3D (point) pos) - (signal 'scan-error - (list "Unbalanced parentheses" (point) (point))))) + (or (and escape-strings + (let ((syntax (syntax-ppss))) + (and (nth 3 syntax) + (nth 8 syntax)) + (goto-char (nth 8 syntax)) + (when (> arg 0) (forward-sexp)) + t)) + (signal 'scan-error + (list "Unbalanced parentheses" (point) (point))))))= (setq arg (- arg inc))))) (defun kill-sexp (&optional arg) --wSil80VsBxRwpf2v3AbOdGrStJBEShLrh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJTRILyAAoJEMAaIROpHW7IgmoP/jJBvSTbASSGyoonVzgvklt8 HGuKBbtkfUOKMYujeLvk0cjzpkk0R7046Rjdq/pHpEkVHXfqxnDVckKUyfNVZ+I1 kSWeVKw72Yd9hDBI+Q33EOSX5IctQd+pb0LMXjfR3u+F+CJXZyLa0Ulbu6xkYJWx 47Gj3C3toznB/ihonzpmu7l+PYDEszLy26czJYjG1yGDPv9lnud6yEGhE7nkvXub +q6MMPghpqlC1T73PunPK0rwARaGiT+ifVkU6DEJ66U75MJynTpeP2YAA3VhgtgK PkuY7GvmEGLOc7pezjdROZlAy9sU7Sdtrt/4Y1wx6tXNl7uQe9zZqR8Ob+WZheKh i/8cjqS/eNcTRKNfamcTIGVLI8if61hA1YHoP96Hi4k+fjDFDSJLcbYsUYsKj4EI tt6eMeA1XUFkKoMg/BCXPQBAgYimkFoVNDBUc+y19MJdopX8wyLxrR6DYqjjFaEY +5b7XdGzW5CYdqM/SfXf9my+NKMsaunZ85edOWsFb7L6OBPJ1525b6tI8mZiXXcm biuFlq8EIN2NoiqAb20nt/jnQopxUPVe1Z8fEIbpEVQldVQyo/3e1C1IRs16JIuN dR4hIvaShSbiP/8+xZCZXmUNT7hHGRzN4G64W9C5lUhfxqGXhQ+MEZrbRRJfUGsi RCHOnSoHsPr70uwtqgTu =F5yP -----END PGP SIGNATURE----- --wSil80VsBxRwpf2v3AbOdGrStJBEShLrh--