[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed 8babcfc 030/166: Make obj state buffer local and
From: |
Clemens Radermacher |
Subject: |
[elpa] externals/objed 8babcfc 030/166: Make obj state buffer local and keep it on movement |
Date: |
Sun, 29 Dec 2019 08:20:55 -0500 (EST) |
branch: externals/objed
commit 8babcfc3a7c8834a842cb09615e2c232b4e02d17
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>
Make obj state buffer local and keep it on movement
Add subword for inner word object
---
objed-objects.el | 30 ++++++++++++++++++++++--------
objed.el | 42 ++++++++++++++++++++++--------------------
2 files changed, 44 insertions(+), 28 deletions(-)
diff --git a/objed-objects.el b/objed-objects.el
index 7b1c460..f0bedf5 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -27,6 +27,8 @@
;; * Bytecomp
+(require 'subword)
+
;; info for byte-comp
(declare-function avy--process "ext:avy")
(declare-function avy--style-fn "ext:avy")
@@ -343,7 +345,7 @@ Positions are stored in a list of the form:
((object-start object-end)
(inner-start inner-end))")
-(defvar objed--obj-state nil
+(defvar-local objed--obj-state nil
"The state used to get object positions.
Either the symbol `whole' or `inner'.")
@@ -1524,12 +1526,19 @@ comments."
(bounds-of-thing-at-point 'symbol))
'identifier)
:get-obj
- (if (and (bound-and-true-p subword-mode)
- (eq this-command 'forward-word))
- (save-excursion
- (forward-word -1)
- (bounds-of-thing-at-point 'word))
- (bounds-of-thing-at-point 'word))
+ (objed-make-object
+ :obounds (if (bound-and-true-p subword-mode)
+ (let ((find-word-boundary-function-table
subword-empty-char-table))
+ (bounds-of-thing-at-point 'word))
+ (bounds-of-thing-at-point 'word))
+ :ibounds (if (and (bound-and-true-p subword-mode)
+ (eq this-command 'forward-word))
+ (save-excursion
+ (forward-word -1)
+ (bounds-of-thing-at-point 'word))
+ (let ((find-word-boundary-function-table
+ subword-find-word-boundary-function-table))
+ (bounds-of-thing-at-point 'word))))
:try-next
(re-search-forward "\\<." nil t)
:try-prev
@@ -2128,7 +2137,12 @@ non-nil the indentation block can contain empty lines."
:atp (or (looking-at "\\_<")
(looking-back "\\_>" 1))
:get-obj
- (bounds-of-thing-at-point 'symbol)
+ (let ((bounds (bounds-of-thing-at-point 'symbol)))
+ (when bounds
+ (objed-make-object
+ :obounds bounds
+ :ibounds (bounds-of-thing-at-point 'word))))
+
:try-next
(objed--next-identifier)
:try-prev
diff --git a/objed.el b/objed.el
index 5c2f283..8510a87 100644
--- a/objed.el
+++ b/objed.el
@@ -124,6 +124,7 @@
(require 'cl-lib)
(require 'nadvice)
(require 'face-remap)
+(require 'subword)
(require 'objed-objects)
@@ -580,7 +581,7 @@ BEFORE and AFTER are forms to execute before/after calling
the command."
(setq this-command ',cmd)
(call-interactively ',cmd)
,after
- (objed--switch-to ',obj)
+ (objed--switch-to ',obj objed--obj-state)
(when (or prb pre)
(cond ((and prb
(= (point) (region-end)))
@@ -615,6 +616,10 @@ selected one."
(message "Indented defun.")))
(call-interactively nc))))
+(defun objed--point-in-periphery ()
+ "Return non-nil if point is in current lines periphery."
+ (<= (point) (save-excursion (back-to-indentation) (point))))
+
(defvar objed-map
(let ((map (make-sparse-keymap)))
;; block unused chars by default
@@ -673,9 +678,16 @@ selected one."
(define-key map "F" 'objed-move-object-forward)
(define-key map "B" 'objed-move-object-backward)
- (define-key map "p" (objed--call-and-switch previous-line line))
+ (define-key map "p" (objed--call-and-switch
+ previous-line line
+ nil
+ (when (objed--point-in-periphery)
+ (back-to-indentation))))
(define-key map "n" (objed--call-and-switch
- next-line line))
+ next-line line
+ nil
+ (when (objed--point-in-periphery)
+ (back-to-indentation))))
(define-key map "P" 'objed-move-line-backward)
(define-key map "N" 'objed-move-line-forward)
@@ -718,7 +730,7 @@ selected one."
(define-key map "o" 'objed-expand-context)
(define-key map "i" 'objed-del-insert)
- (define-key map "t" 'objed-shrink-context)
+ (define-key map "t" 'objed-toggle-state)
(define-key map "j" 'objed-toggle-side)
;; marking/unmarking
@@ -1862,26 +1874,16 @@ Default to sexp at point."
(t
(goto-char (objed--beg)))))))
-
-(defun objed-shrink-context ()
+(defun objed-toggle-state ()
"Shrink current object.
Switches to inner object or object inside current one."
(interactive)
- (if (eq objed--object 'sexp)
- (save-excursion
- (objed-context-object))
- (if (objed--inner-p)
- (save-excursion
- (goto-char (objed--end))
- (objed--switch-to 'sexp))))
- (let ((sdiff (abs (- (point) (objed--beg))))
- (ediff (abs (- (point) (objed--end)))))
- (objed--reverse)
- (goto-char (cond ((> ediff sdiff)
- (objed--beg))
- (t
- (objed--end))))))
+ (if (bound-and-true-p subword-mode)
+ (subword-mode -1)
+ (unless (objed--inner-p)
+ (subword-mode 1)))
+ (objed--toggle-state))
(defun objed-expand-context ()
- [elpa] externals/objed dc673b8 022/166: Fix for mc counting non fake cursor as cursor, (continued)
- [elpa] externals/objed dc673b8 022/166: Fix for mc counting non fake cursor as cursor, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 252a1d3 021/166: For brackets, strings and comments switch to sexp on continuation, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 0fa1ea3 024/166: Default to sexp for continuation object, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed be2c78c 027/166: Fix word object for subword-mode, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 0956db5 029/166: Don't add additional undo bounds for numeric repeats, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 781f0ee 031/166: Make word object behave correctly with superword/subword-mode, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed a16418c 040/166: Refactor object-toggle-state, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed f9c3819 020/166: Tweak sexp object again, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 2701f73 026/166: Fix backward kill for continuation, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed bddcb432 032/166: Fix dosctring, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 8babcfc 030/166: Make obj state buffer local and keep it on movement,
Clemens Radermacher <=
- [elpa] externals/objed e6d306b 033/166: Don't exclude current object for objed-ace, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 32221a6 041/166: Remember object type for marked object, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 74204af 037/166: Add ability to jump to objects inside current one, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 87cdeee 039/166: Improve toggle state, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 6ae9bff 042/166: When repeating backward/forward until proceed to object boundary, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 1b50645 048/166: Update docstring, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed db01e08 046/166: Undo last commit, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 25714dc 060/166: Don't try to be smart with electric wrap, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 06f4abc 043/166: Improve repeat behavior for backward/forward until context, Clemens Radermacher, 2019/12/29
- [elpa] externals/objed 2a634b8 054/166: Make append mode global, Clemens Radermacher, 2019/12/29