[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed e6d2de7 2/9: Improve beg/eof block
From: |
Clemens Radermacher |
Subject: |
[elpa] externals/objed e6d2de7 2/9: Improve beg/eof block |
Date: |
Mon, 4 Mar 2019 07:46:21 -0500 (EST) |
branch: externals/objed
commit e6d2de761ce1f008288f896ad088046511b405c8
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>
Improve beg/eof block
---
objed.el | 73 +++++++++++++---------
.../emacs-lisp-mode/00_activate/beginning-of-line | 3 +-
test/tests/emacs-lisp-mode/expansion/block_1 | 4 +-
3 files changed, 46 insertions(+), 34 deletions(-)
diff --git a/objed.el b/objed.el
index ac4a14e..5aff13a 100644
--- a/objed.el
+++ b/objed.el
@@ -395,7 +395,9 @@ If this list contains an entry for an operation, the
exit function is called after execution of the operation.")
(defvar objed--after-init-alist
- '((move-end-of-line . objed--object-trailing-line)
+ '((move-beginning-of-line . objed--object-until-bol)
+ (org-beginning-of-line . objed--object-until-bol)
+ (move-end-of-line . objed--object-trailing-line)
(org-end-of-line . objed--object-trailing-line)
(back-to-indentation . objed--until-start)
(beginning-of-buffer . objed--until-start)
@@ -1103,6 +1105,13 @@ See `objed-cmd-alist'."
(when objed--current-obj
(goto-char (objed--beg))))
+(defun objed--object-until-bol (pos)
+ "Activate leading part from POS."
+ (unless (<= pos (objed--indentation-position))
+ (objed--reverse))
+ (goto-char (objed--beg))
+ (objed--change-to :end pos :iend pos))
+
(defun objed--object-trailing-line (pos)
"Activate trailing part from POS."
(unless (eq objed--obj-state 'inner)
@@ -1448,7 +1457,21 @@ block, paragraph and other 'line based' objects.
See also `objed--block-objects'."
(interactive)
- (cond ((eq last-command this-command)
+ (when (not (eq last-command this-command))
+ ;; get all which make sense from starting point
+ (setq blocks
+ (cl-remove-duplicates
+ (objed--get-blocks
+ (if (eq last-command 'move-beginning-of-line)
+ nil 'line)
+ #'objed--beg)
+ :test (lambda (a b)
+ (let ((as (objed--beg (car (nthcdr 3 a))))
+ (bs (objed--beg (car (nthcdr 3 b)))))
+ (or (eq as bs)
+ (>= as (point))))))))
+ (cond ((or (eq last-command this-command)
+ (eq last-command 'move-beginning-of-line))
(when blocks
(let ((end (objed--end)))
(objed--restore-state (pop blocks))
@@ -1460,18 +1483,7 @@ See also `objed--block-objects'."
(objed--indentation-position))
'inner))
(objed--change-to :end (point) :iend (point))
- (goto-char (objed--beg))
- ;; get all which make sense from starting point
- (setq blocks
- (cl-remove-duplicates
- (objed--get-blocks
- nil ;;'line after inner...
- #'objed--beg)
- :test (lambda (a b)
- (let ((as (objed--beg (car (nthcdr 3 a))))
- (bs (objed--beg (car (nthcdr 3 b)))))
- (or (eq as bs)
- (>= as (point)))))))))))
+ (goto-char (objed--beg))))))
(let ((blocks nil))
@@ -1485,7 +1497,22 @@ proceed to end of the indentation block, paragraph and
other
See also `objed--block-objects'."
(interactive)
- (cond ((eq last-command this-command)
+ (when (not (eq last-command this-command))
+ (setq blocks
+ (cl-remove-duplicates
+ (nreverse
+ (objed--get-blocks
+ 'line
+ #'objed--end
+ ;; better for most cases
+ 'inner))
+ :test (lambda (a b)
+ (let ((as (objed--end (car (nthcdr 3 a))))
+ (bs (objed--end (car (nthcdr 3 b)))))
+ (or (eq as bs)
+ (<= as (point))))))))
+ (cond ((or (eq last-command this-command)
+ (eq last-command 'move-end-of-line))
(when blocks
(let ((beg (objed--beg)))
(objed--restore-state (pop blocks))
@@ -1494,21 +1521,7 @@ See also `objed--block-objects'."
(t
(objed--switch-to 'line 'inner)
(objed--change-to :beg (point) :ibeg (point))
- (goto-char (objed--end))
- ;; get all which make sense from starting point
- (setq blocks
- (cl-remove-duplicates
- (nreverse
- (objed--get-blocks
- 'line
- #'objed--end
- ;; better for most cases
- 'inner))
- :test (lambda (a b)
- (let ((as (objed--end (car (nthcdr 3 a))))
- (bs (objed--end (car (nthcdr 3 b)))))
- (or (eq as bs)
- (<= as (point)))))))))))
+ (goto-char (objed--end))))))
(defun objed-forward-symbol ()
diff --git a/test/tests/emacs-lisp-mode/00_activate/beginning-of-line
b/test/tests/emacs-lisp-mode/00_activate/beginning-of-line
index 571073f..9a2f9e0 100644
--- a/test/tests/emacs-lisp-mode/00_activate/beginning-of-line
+++ b/test/tests/emacs-lisp-mode/00_activate/beginning-of-line
@@ -4,5 +4,4 @@ C-a
Testing line he|re
;;;;
-|<Testing line here
->
\ No newline at end of file
+|<Testing line he>re
diff --git a/test/tests/emacs-lisp-mode/expansion/block_1
b/test/tests/emacs-lisp-mode/expansion/block_1
index f090788..03d916c 100644
--- a/test/tests/emacs-lisp-mode/expansion/block_1
+++ b/test/tests/emacs-lisp-mode/expansion/block_1
@@ -17,5 +17,5 @@ C-a
;; More on same level
;; Some text
-|<;; and more text
->
+|<;; and >more text
+
- [elpa] externals/objed updated (65d3430 -> 98a3a35), Clemens Radermacher, 2019/03/04
- [elpa] externals/objed 5dd9ed0 1/9: Make C-x C-key actions available via x prefix, Clemens Radermacher, 2019/03/04
- [elpa] externals/objed 0e18666 3/9: Activate on recenter, Clemens Radermacher, 2019/03/04
- [elpa] externals/objed 77f2b75 8/9: Add more window control commands to op map, Clemens Radermacher, 2019/03/04
- [elpa] externals/objed 11e056c 6/9: Move more setting into buffer reset, Clemens Radermacher, 2019/03/04
- [elpa] externals/objed 59515c7 5/9: Don't skip ws when toggling sides, Clemens Radermacher, 2019/03/04
- [elpa] externals/objed e6d2de7 2/9: Improve beg/eof block,
Clemens Radermacher <=
- [elpa] externals/objed f5876e9 7/9: Make buffer switch possible with objed staying active (other-window), Clemens Radermacher, 2019/03/04
- [elpa] externals/objed ee24332 4/9: Fix resetting settings when buffer is not live anymore, Clemens Radermacher, 2019/03/04
- [elpa] externals/objed 98a3a35 9/9: Vesion bump, Clemens Radermacher, 2019/03/04