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

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

[nongnu] elpa/multiple-cursors 7ddda85 312/434: Added vertical align com


From: ELPA Syncer
Subject: [nongnu] elpa/multiple-cursors 7ddda85 312/434: Added vertical align commands
Date: Sat, 7 Aug 2021 09:20:49 -0400 (EDT)

branch: elpa/multiple-cursors
commit 7ddda8527b8126fc26a6700136497f7dd4a0e525
Author: Patrick Seebauer <patrick.seebuaer@web.de>
Commit: Patrick Seebauer <patrick.seebuaer@web.de>

    Added vertical align commands
    
    Squashed commit of the following:
    
    commit 243a14e69501bf938eea54449782f43be2084ef2
    Author: Patrick Seebauer <patrick.seebuaer@web.de>
    Date:   Fri Sep 5 18:06:19 2014 +0200
    
        removed uniq line check and added warning in the docs about cursors on 
the same line.
    
    commit 438658ef0358b0a1540c2663aedba0253150a007
    Author: Patrick Seebauer <patrick.seebuaer@web.de>
    Date:   Fri Sep 5 17:59:55 2014 +0200
    
        fixed tests for commands with character inputs
    
    commit c565969c6bb01e37ec42cfe311ada87643e38ccc
    Author: Patrick Seebauer <patrick.seebuaer@web.de>
    Date:   Fri Sep 5 17:36:41 2014 +0200
    
        renamed to vertical align, added non-whitespace option
    
    commit 941c40a319f571680017293681ff7d796ba4e1f4
    Author: Patrick Seebauer <patrick.seebuaer@web.de>
    Date:   Fri Sep 5 16:58:14 2014 +0200
    
        added test
    
    commit d9a4a55ebde9b51c3f62b14948529759aaaa9bf6
    Author: Patrick Seebauer <patrick.seebuaer@web.de>
    Date:   Tue Sep 2 19:32:49 2014 +0200
    
        added interactives, added abort if cursors are on the same line
    
    commit 12d01fe4db5109061533b0524d99177d1204eb85
    Author: Patrick Seebauer <patrick.seebuaer@web.de>
    Date:   Tue Sep 2 18:55:47 2014 +0200
    
        some adjustments
    
    commit 9fddf98b6cd1bb68c334ab46fe1c9bcc08397796
    Author: Patrick Seebauer <patrick.seebuaer@web.de>
    Date:   Tue Sep 2 18:47:39 2014 +0200
    
        rough sketch
---
 features/vertical-align.feature | 27 +++++++++++++++++++++++++++
 mc-separate-operations.el       | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)

diff --git a/features/vertical-align.feature b/features/vertical-align.feature
new file mode 100644
index 0000000..3a5a124
--- /dev/null
+++ b/features/vertical-align.feature
@@ -0,0 +1,27 @@
+Feature: Align cursors with whitespaces
+    
+  Scenario: Vertical aligning with `x'
+    Given I have cursors at "word" in :
+    """
+    One word
+    Another word
+    """
+    And I press "<<mc/vertical-align>> \170"
+    Then I should see:
+    """
+    One xxxxword
+    Another word
+    """
+
+  Scenario: Vertical aligning with space
+    Given I have cursors at "word" in :
+    """
+    One word
+    Another word
+    """
+    And I press "<<mc/vertical-align-with-space>>"
+    Then I should see:
+    """
+    One     word
+    Another word
+    """
diff --git a/mc-separate-operations.el b/mc-separate-operations.el
index abbfaee..7543232 100644
--- a/mc-separate-operations.el
+++ b/mc-separate-operations.el
@@ -86,5 +86,37 @@
   (setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<))
   (mc--replace-region-strings))
 
+
+;;;###autoload
+(defun mc/vertical-align (character)
+  "Aligns all cursors vertically with a given CHARACTER to the one with the
+highest colum number (the rightest)
+Aborts if the some cursors are on the same line.
+Might not behave as intended if more than one cursors are on the same line."
+  (interactive "c")
+  (let ((rightest-column (current-column)))
+    (mc/execute-command-for-all-cursors 
+     (lambda () "get the rightest cursor"
+       (interactive)
+       (setq rightest-column (max (current-column) rightest-column))
+       ))
+    (mc/execute-command-for-all-cursors 
+     (lambda () 
+       (interactive)
+       (let ((missing-spaces (- rightest-column (current-column))))
+        (save-excursion (insert (make-string missing-spaces character)))
+        (forward-char missing-spaces)
+        )
+       ))
+      )
+    )
+
+;;;###autoload
+(defun mc/vertical-align-with-space ()
+  "Aligns all cursors with whitespace like `mc/vertical-align' does"
+  (interactive)
+  (mc/vertical-align 32)
+  )
+
 (provide 'mc-separate-operations)
 ;;; mc-separate-operations.el ends here



reply via email to

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