Anonymous avatar Anonymous committed 668763b

Make C-e bounce to end of longest line in cua rectangle if this is active

Comments (0)

Files changed (1)


+(defun my-cua-get-longest-line ()
+  (-max (mapcar 'length
+                (split-string
+                 (buffer-substring-no-properties (cua--rectangle-top) (cua--rectangle-bot))
+                 "\n"))))
 (defun my-end-of-code-or-line (&optional arg)
   "Move to the end of code.  If already there, move to the end of line,
 that is after the possible comment.  If at the end of line, move
 If the point is in org table, first go to the last non-whitespace
 of the cell, then to the end of line.
+If CUA rectangle is active, alternate between end of current
+line, end of code, and end of the longest line in rectangle.
   (serious |code here)1 ;; useless commend2
                        (progn (end-of-line-lov)
-                     (point)))))
-        (if (= (point) eoc)
-            (end-of-line-lov)
-          (goto-char eoc)))))))
+                     (point))))
+            ;; end of rectangle in cua-rect mode
+            (eor (when cua--rectangle (my-cua-get-longest-line))))
+        (cond
+         ((= (point) eoc)
+          (end-of-line-lov))
+         ((= (point) (progn (end-of-line-lov) (point)))
+          (if (and cua--rectangle
+                   (/= (1+ (aref cua--rectangle 3)) eor))
+              (cua-resize-rectangle-right (- eor (current-column) 1))
+            (goto-char eoc)))
+         (t (goto-char eoc))))))))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.