[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark 913ccec9b8: Have embark-{next, previous}-symbol
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark 913ccec9b8: Have embark-{next, previous}-symbol act on symbol at point |
Date: |
Fri, 4 Mar 2022 23:57:26 -0500 (EST) |
branch: externals/embark
commit 913ccec9b8423396e7c5327a9efa7685bdb04782
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Have embark-{next,previous}-symbol act on symbol at point
The old way, which prompted for a symbol, was very similar to existing
commands like isearch-forward-symbol or word-search-forward; and in
particular I couldn't really imagine anyone wanting to use the embark
versions directly (i.e., not through embark-act) given the existence
of isearch-forward-symbol, which even has a default binding. But these
new versions that act on the symbol at point are something you might
actually want to bind directly. And for the usage as actions they work
exactly as before.
---
embark.el | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/embark.el b/embark.el
index 36ec95979e..0402a93cba 100644
--- a/embark.el
+++ b/embark.el
@@ -3624,25 +3624,29 @@ minibuffer, which means it can be used as an Embark
action."
(unhighlight-regexp regexp)
(highlight-symbol-at-point))))
-(defun embark-next-symbol (symbol)
- "Jump to next occurrence of SYMBOL.
+(defun embark-next-symbol ()
+ "Jump to next occurrence of symbol at point.
The search respects symbol boundaries."
- (interactive "sSymbol: ")
- (let ((regexp (format "\\_<%s\\_>" (regexp-quote symbol))))
- (when (looking-at regexp)
- (forward-symbol 1))
- (unless (re-search-forward regexp nil t)
- (user-error "Symbol `%s' not found" symbol))))
-
-(defun embark-previous-symbol (symbol)
- "Jump to previous occurrence SYMBOL.
+ (interactive)
+ (if-let ((symbol (thing-at-point 'symbol)))
+ (let ((regexp (format "\\_<%s\\_>" (regexp-quote symbol))))
+ (when (looking-at regexp)
+ (forward-symbol 1))
+ (unless (re-search-forward regexp nil t)
+ (user-error "Symbol `%s' not found" symbol)))
+ (user-error "No symbol at point")))
+
+(defun embark-previous-symbol ()
+ "Jump to previous occurrence of symbol at point.
The search respects symbol boundaries."
- (interactive "sSymbol: ")
- (let ((regexp (format "\\_<%s\\_>" (regexp-quote symbol))))
- (when (looking-back regexp (- (point) (length symbol)))
- (forward-symbol -1))
- (unless (re-search-backward regexp nil t)
- (user-error "Symbol `%s' not found" symbol))))
+ (interactive)
+ (if-let ((symbol (thing-at-point 'symbol)))
+ (let ((regexp (format "\\_<%s\\_>" (regexp-quote symbol))))
+ (when (looking-back regexp (- (point) (length symbol)))
+ (forward-symbol -1))
+ (unless (re-search-backward regexp nil t)
+ (user-error "Symbol `%s' not found" symbol)))
+ (user-error "No symbol at point")))
(defun embark-compose-mail (address)
"Compose email to ADDRESS."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/embark 913ccec9b8: Have embark-{next, previous}-symbol act on symbol at point,
ELPA Syncer <=