emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ELPA-diffs] ELPA branch, master, updated. 0fb7ebfc7ecf27f9a0d7642897571


From: Barry O'Reilly
Subject: [ELPA-diffs] ELPA branch, master, updated. 0fb7ebfc7ecf27f9a0d76428975716c1760f9474
Date: Wed, 23 Oct 2013 15:27:35 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "ELPA".

The branch, master has been updated
       via  0fb7ebfc7ecf27f9a0d76428975716c1760f9474 (commit)
      from  1caa02a78b4b56aa56c5c2c012f57abf156bb0a9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0fb7ebfc7ecf27f9a0d76428975716c1760f9474
Author: Barry O'Reilly <address@hidden>
Date:   Wed Oct 23 11:23:41 2013 -0400

    * adjust-parens.el: Generalize to also work with alternative list
    closing chars, such as Clojure's brackets.

diff --git a/packages/adjust-parens/adjust-parens.el 
b/packages/adjust-parens/adjust-parens.el
index 003302d..066dd0f 100644
--- a/packages/adjust-parens/adjust-parens.el
+++ b/packages/adjust-parens/adjust-parens.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2013  Free Software Foundation, Inc.
 
 ;; Author: Barry O'Reilly <address@hidden>
-;; Version: 1.1
+;; Version: 1.2
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -21,8 +21,8 @@
 ;;; Commentary:
 ;;
 ;; This package provides commands for indenting and dedenting Lisp
-;; code such that close parentheses are automatically adjusted to be
-;; consistent with the new level of indentation.
+;; code such that close parentheses and brackets are automatically
+;; adjusted to be consistent with the new level of indentation.
 ;;
 ;; When reading Lisp, the programmer pays attention to open parens and
 ;; the close parens on the same line. But when a sexp spans more than
@@ -101,7 +101,7 @@
 ;;   - Consider taking a region as input in order to indent a sexp and
 ;;     its siblings in the region. Dedenting would not take a region.
 
-(require 'cl)
+(require 'cl-lib)
 
 (defun last-sexp-with-relative-depth (from-pos to-pos rel-depth)
   "Parsing sexps from FROM-POS (inclusive) to TO-POS (exclusive),
@@ -167,22 +167,25 @@ it moved to.
 If there's no close parens to move, either return nil or allow
 scan-error to propogate up."
   (save-excursion
-    (let ((deleted-paren-pos
-           (save-excursion
-             (beginning-of-line)
-             ;; Account for edge case when point has no sexp before it
-             ;;
-             ;; This is primarily to avoid funny behavior when there
-             ;; is no sexp between bob and point.
-             (if (not (adjust-parens-check-prior-sexp))
-                 nil
-               ;; If the sexp at point is a list,
-               ;; delete its closing paren
-               (when (eq (scan-lists (point) 1 0)
-                         (scan-sexps (point) 1))
-                 (forward-sexp)
-                 (delete-char -1)
-                 (point))))))
+    (let* ((deleted-paren-char nil)
+           (deleted-paren-pos
+            (save-excursion
+              (beginning-of-line)
+              ;; Account for edge case when point has no sexp before it
+              ;;
+              ;; This is primarily to avoid funny behavior when there
+              ;; is no sexp between bob and point.
+              (if (not (adjust-parens-check-prior-sexp))
+                  nil
+                ;; If the sexp at point is a list,
+                ;; delete its closing paren
+                (when (eq (scan-lists (point) 1 0)
+                          (scan-sexps (point) 1))
+                  (forward-sexp)
+                  (setq deleted-paren-char (char-before))
+                  (delete-char -1)
+                  (point))))))
+      ;; Invariant: deleted-paren-pos nil iff deleted-paren-char nil
       (when deleted-paren-pos
         (let ((sexp-to-close
                (save-excursion
@@ -195,7 +198,7 @@ scan-error to propogate up."
             (forward-sexp))
           ;; Note: when no sexp-to-close found, line is empty. So put
           ;; close paren after point.
-          (insert ")")
+          (insert deleted-paren-char)
           (list deleted-paren-pos (point)))))))
 
 (defun adjust-close-paren-for-dedent ()
@@ -209,13 +212,16 @@ it moved to.
 If there's no close parens to move, either return nil or allow
 scan-error to propogate up."
   (save-excursion
-    (let ((deleted-paren-pos
-           (save-excursion
-             (when (< (point)
-                      (progn (up-list)
-                             (point)))
-               (delete-char -1)
-               (point)))))
+    (let* ((deleted-paren-char nil)
+           (deleted-paren-pos
+            (save-excursion
+              (when (< (point)
+                       (progn (up-list)
+                              (point)))
+                (setq deleted-paren-char (char-before))
+                (delete-char -1)
+                (point)))))
+      ;; Invariant: deleted-paren-pos nil iff deleted-paren-char nil
       (when deleted-paren-pos
         (let ((sexp-to-close
                ;; Needs to work when dedenting in an empty list, in
@@ -230,7 +236,7 @@ scan-error to propogate up."
               (forward-sexp)
             (backward-up-list)
             (forward-char 1))
-          (insert ")")
+          (insert deleted-paren-char)
           ;; The insertion makes deleted-paren-pos off by 1
           (list (1+ deleted-paren-pos)
                 (point)))))))

-----------------------------------------------------------------------

Summary of changes:
 packages/adjust-parens/adjust-parens.el |   64 +++++++++++++++++--------------
 1 files changed, 35 insertions(+), 29 deletions(-)


hooks/post-receive
-- 
ELPA



reply via email to

[Prev in Thread] Current Thread [Next in Thread]