branch: externals/objed
commit be0cd7c4b7b7e673a749e2008db7d6b58aaa5270
Author: Clemens Radermacher <[email protected]>
Commit: Clemens Radermacher <[email protected]>
Fix identifier immediate jumping if used as last command
---
objed-objects.el | 25 +------------------------
objed.el | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/objed-objects.el b/objed-objects.el
index 5de5a4c..8917bae 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -2063,32 +2063,9 @@ non-nil the indentation block can contain empty lines."
(eq real-this-command #'objed-prev-identifier))
(run-at-time 0 nil (apply-partially #'message "First
one!")))))))))
-(defun objed--get-ident-format ()
- "Get format string for identifier."
- (let ((sym (or (symbol-at-point)
- (and (re-search-forward "\\_<" nil t)
- (symbol-at-point)))))
- (when sym
- (format "\\_<%s\\_>" sym))))
-;;;###autoload
-(defun objed-first-identifier ()
- "Move to first instance of identifier at point."
- (interactive)
- (let ((ident (objed--get-ident-format)))
- (when ident
- (goto-char (point-min))
- (when (re-search-forward ident nil t)
- (goto-char (match-beginning 0))))))
-;;;###autoload
-(defun objed-last-identifier ()
- "Move to last instance of identifier at point."
- (interactive)
- (let ((ident (objed--get-ident-format)))
- (when ident
- (goto-char (point-max))
- (re-search-backward ident nil t))))
+
(objed-define-object nil section
diff --git a/objed.el b/objed.el
index 0551cb8..ba3de8c 100644
--- a/objed.el
+++ b/objed.el
@@ -1892,6 +1892,39 @@ back to `objed-initial-object' if no match found."
(goto-char (objed--iend))
(objed--change-to :beg pos :ibeg pos))))
+(defun objed--get-ident-format ()
+ "Get format string for identifier."
+ (let ((sym (or (symbol-at-point)
+ (and (re-search-forward "\\_<" nil t)
+ (symbol-at-point)))))
+ (when sym
+ (format "\\_<%s\\_>" sym))))
+
+;;;###autoload
+(defun objed-first-identifier ()
+ "Move to first instance of identifier at point."
+ (interactive)
+ (let ((ident (objed--get-ident-format)))
+ (when ident
+ (goto-char (point-min))
+ (when (re-search-forward ident nil t)
+ (goto-char (match-beginning 0))))))
+
+;;;###autoload
+(defun objed-last-identifier ()
+ "Move to last instance of identifier at point."
+ (interactive)
+ (let ((ident (objed--get-ident-format)))
+ (when ident
+ (goto-char (point-max))
+ (re-search-backward ident nil t))))
+
+;;;###autoload
+(defun objed-identifier ()
+ "Activate object with identifier at point."
+ (interactive)
+ (objed--init 'identifier))
+
(defun objed-toggle-side ()
"Move to other side of object.
@@ -3327,7 +3360,7 @@ whitespace they build a sequence."
(define-key map (kbd "M-[") 'objed-beg-of-object-at-point)
(define-key map (kbd "M-]") 'objed-end-of-object-at-point)
(define-key map (kbd "C-,") 'objed-prev-identifier)
- (define-key map (kbd "C-.") 'objed-identifier-object)
+ (define-key map (kbd "C-.") 'objed-identifier)
(define-key map (kbd "C-<") 'objed-first-identifier)
(define-key map (kbd "C->") 'objed-last-identifier)
map)