[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed 9225e77 194/216: Improve objed-extend
From: |
Stefan Monnier |
Subject: |
[elpa] externals/objed 9225e77 194/216: Improve objed-extend |
Date: |
Tue, 8 Jan 2019 12:29:37 -0500 (EST) |
branch: externals/objed
commit 9225e77b467d058879631ac8ba90b58ea77d2b96
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>
Improve objed-extend
---
objed-objects.el | 12 ++++++++++--
objed.el | 33 ++++++++++++++++++++++-----------
2 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/objed-objects.el b/objed-objects.el
index bb52b68..e69d0e9 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -400,6 +400,12 @@ OBJ is the object to use and defaults to
`objed--current-obj'."
(let ((obj (or obj objed--current-obj)))
(objed--apply #'max obj)))
+(defun objed--basic-p ()
+ "Return non-nil if current object is a basic object.
+
+From basic objects `objed' starts expanding to context objects."
+ (memq objed--object '(line word char region buffer)))
+
(defun objed--current (&optional obj)
"Get the current range of interest.
@@ -409,8 +415,10 @@ otherwise the its the head of object OBJ which defaults to
(let ((obj (or obj objed--current-obj)))
(cond ((region-active-p)
(list (region-beginning)
- (max (objed--end)
- (region-end))))
+ (if (objed--basic-p)
+ (region-end)
+ (max (objed--end)
+ (region-end)))))
(t
(car obj)))))
diff --git a/objed.el b/objed.el
index 798b6dd..296eb52 100644
--- a/objed.el
+++ b/objed.el
@@ -562,6 +562,23 @@ BEFORE and AFTER are forms to execute before/after calling
the command."
(objed--switch-to ',obj)))
+(defun objed--forward-word ()
+ (interactive)
+ (if (and (eq last-command 'objed-extend)
+ (eq objed--object 'word)
+ (looking-at "\\<"))
+ (objed-exchange-point-and-mark)
+ (call-interactively 'forward-word)))
+
+(defun objed--backward-word ()
+ (interactive)
+ (if (and (eq last-command 'objed-extend)
+ (eq objed--object 'word)
+ (looking-back "\\>" 1))
+ (objed-exchange-point-and-mark)
+ (call-interactively 'backward-word)))
+
+
(defvar objed-map
(let ((map (make-sparse-keymap)))
;; block unused chars by default
@@ -610,11 +627,10 @@ BEFORE and AFTER are forms to execute before/after
calling the command."
(define-key map "F" 'objed-move-char-forward)
(define-key map "s" (objed--call-and-switch
- forward-word word
- (when (and (eq last-command 'objed-extend)
- (looking-at "\\<"))
- (objed-exchange-point-and-mark))))
- (define-key map "r" (objed--call-and-switch backward-word word))
+ objed--forward-word
+ word))
+ (define-key map "r" (objed--call-and-switch
+ objed--backward-word word))
(define-key map "S" 'objed-move-word-forward)
(define-key map "R" 'objed-move-word-backward)
@@ -1479,11 +1495,6 @@ Skips strings and comments."
(defvar objed--context-objects '(string bracket tag comment)
"List of objects to be choosen by context.")
-(defun objed--basic-p ()
- "Return non-nil if current object is a basic object.
-
-From basic objects `objed' starts expanding to context objects."
- (memq objed--object '(line word char region buffer)))
(defun objed--get-context-state (from)
"Get state to be used by expand commands.
@@ -1720,7 +1731,7 @@ movement commands."
(setq objed--extend-cookie
(face-remap-add-relative 'objed-hl
'objed-extend)))
- (unless (= (point) (objed--end))
+ (when (< (objed--beg) (point) (objed--end))
(goto-char (objed--beg)))
(push-mark (if (or (>= (point) (objed--end))
(eq objed--object 'char))
- [elpa] externals/objed 74b3595 181/216: Adjust textblock object, (continued)
- [elpa] externals/objed 74b3595 181/216: Adjust textblock object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 3a983ab 205/216: Read arguments of rcmd after region is established, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 6092485 173/216: Ignore cases where object could not be found (range = nil), Stefan Monnier, 2019/01/08
- [elpa] externals/objed 736c331 193/216: Improve undo, repeat will proceed undo in object region, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 723fe2c 204/216: Adjust objed-activate again, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 7c2bc2f 206/216: Inline eval-rspec, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 3c8f74d 186/216: Make forward-word work like the other commands for extend, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 47ff6db 207/216: Provide default for replace-op, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 9ddefdb 172/216: Fix empty buffer error for exit-op, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 3096642 001/216: Initial commit, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 9225e77 194/216: Improve objed-extend,
Stefan Monnier <=
- [elpa] externals/objed 5d7bda7 200/216: Fix typo (lexical binding), Stefan Monnier, 2019/01/08
- [elpa] externals/objed 8fc9649 199/216: Fix markup, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 806c681 209/216: Improve objed-activate conditions, Stefan Monnier, 2019/01/08
- [elpa] externals/objed d7a7c74 175/216: Improve python defun object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 1af3cc7 190/216: Allow minibuffer input in non interactive function ops, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 101fd9f 179/216: Improve org section object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 60d4e97 214/216: Dont init when starting commit message, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 72f1807 188/216: Use anzu if available, Stefan Monnier, 2019/01/08
- [elpa] externals/objed a30956f 202/216: Make objed-activate callable from hooks (init with char), Stefan Monnier, 2019/01/08
- [elpa] externals/objed ea2ac9e 137/216: Face used in mode line should be less prominent, Stefan Monnier, 2019/01/08