[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/symbol-overlay ad77d6cd1e 113/152: add symbol-overlay-jump
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/symbol-overlay ad77d6cd1e 113/152: add symbol-overlay-jump-first/last |
Date: |
Thu, 7 Jul 2022 12:04:20 -0400 (EDT) |
branch: elpa/symbol-overlay
commit ad77d6cd1e48adc7345503ca86f3e81877033703
Author: wolray <wolray@foxmail.com>
Commit: wolray <wolray@foxmail.com>
add symbol-overlay-jump-first/last
---
readme.md | 4 ++++
symbol-overlay.el | 60 +++++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/readme.md b/readme.md
index 45e573eb51..39316a676c 100644
--- a/readme.md
+++ b/readme.md
@@ -9,6 +9,10 @@ Highlight symbols with overlays while providing a keymap for
various operations
What's New!
---
+### 20190306:
+
+New command `symbol-overlay-jump-first` and `symbol-overlay-jump-last` are now
enabled.
+
### 20190305:
New customizable variable `symbol-overlay-displayed-window` is introduced to
control the overlay behavior at `symbol-overlay-mode`. If it is non-nil,
occurrences outside the displayed window will not be counted or highlighted.
diff --git a/symbol-overlay.el b/symbol-overlay.el
index 44eccf56de..184c6cb970 100644
--- a/symbol-overlay.el
+++ b/symbol-overlay.el
@@ -211,12 +211,13 @@ You can re-bind the commands to any keys you prefer.")
(remove-hook 'post-command-hook 'symbol-overlay-post-command t)
(symbol-overlay-remove-temp)))
-(defun symbol-overlay-get-list (&optional symbol car-or-cdr exclude)
+(defun symbol-overlay-get-list (dir &optional symbol exclude)
"Get all highlighted overlays in the buffer.
If SYMBOL is non-nil, get the overlays that belong to it.
-CAR-OR-CDR must a symbol whose value is 'car or 'cdr, if not nil.
+DIR is an integer.
If EXCLUDE is non-nil, get all overlays excluding those belong to SYMBOL."
- (let ((lists (progn (overlay-recenter (point)) (overlay-lists))))
+ (let ((lists (progn (overlay-recenter (point)) (overlay-lists)))
+ (func (if (> dir 0) 'cdr (if (< dir 0) 'car nil))))
(seq-filter
'(lambda (ov)
(let ((value (overlay-get ov 'symbol)))
@@ -224,7 +225,7 @@ If EXCLUDE is non-nil, get all overlays excluding those
belong to SYMBOL."
(or (not symbol)
(if (string= value symbol) (not exclude)
(and exclude (not (string= value ""))))))))
- (if car-or-cdr (funcall car-or-cdr lists)
+ (if func (funcall func lists)
(append (car lists) (cdr lists))))))
(defun symbol-overlay-get-symbol (&optional string noerror)
@@ -242,7 +243,7 @@ If NOERROR is non-nil, just return nil when no symbol is
found."
(defun symbol-overlay-maybe-remove (keyword)
"Delete the KEYWORD list and all its overlays."
(when keyword
- (mapc 'delete-overlay (symbol-overlay-get-list (car keyword)))
+ (mapc 'delete-overlay (symbol-overlay-get-list 0 (car keyword)))
(setq symbol-overlay-keywords-alist
(delq keyword symbol-overlay-keywords-alist))
(cddr keyword)))
@@ -283,7 +284,7 @@ depending on SCOPE and WINDOW."
(defun symbol-overlay-remove-temp ()
"Delete all temporary overlays."
- (mapc 'delete-overlay (symbol-overlay-get-list ""))
+ (mapc 'delete-overlay (symbol-overlay-get-list 0 ""))
(setq symbol-overlay-temp-symbol nil))
(defun symbol-overlay-maybe-put-temp ()
@@ -377,8 +378,8 @@ If KEYWORD is non-nil, remove it then use its color on new
overlays."
If SHOW-COLOR is non-nil, display the color used by current overlay."
(when keyword
(let* ((symbol (car keyword))
- (before (symbol-overlay-get-list symbol 'car))
- (after (symbol-overlay-get-list symbol 'cdr))
+ (before (symbol-overlay-get-list -1 symbol))
+ (after (symbol-overlay-get-list 1 symbol))
(count (length before)))
(message (concat (substring symbol 3 -3)
": %d/%d"
@@ -390,7 +391,7 @@ If SHOW-COLOR is non-nil, display the color used by current
overlay."
(defun symbol-overlay-match-keyword-list (symbol keywords)
"Return non-nil is SYMBOL is among KEYWORDS.
KEYWORDS is a list of strings. SYMBOL is expected to include
-leading \\< and trailing \\>, as per the return value of
+leading \\_< and trailing \\_>, as the return value of
`symbol-overlay-get-symbol'."
(cl-find (substring symbol 3 -3) keywords :test #'string=))
@@ -497,16 +498,20 @@ BEG, END and LEN are the beginning, end and length of
changed text."
(unless (minibufferp)
(let* ((symbol (symbol-overlay-get-symbol))
(keyword (symbol-overlay-assoc symbol)))
+ (symbol-overlay-adjust-position)
(if keyword
(if (symbol-overlay-maybe-reput symbol keyword)
(symbol-overlay-maybe-count keyword)
(symbol-overlay-maybe-remove keyword)
(symbol-overlay-maybe-put-temp))
- (and (looking-at-p "\\_>") (backward-char))
(symbol-overlay-maybe-count
(symbol-overlay-put-all symbol symbol-overlay-scope)
t)))))
+(defun symbol-overlay-adjust-position ()
+ "Backward one char if at the end of the symbol."
+ (when (looking-at-p "\\_>") (backward-char)))
+
;;;###autoload
(defun symbol-overlay-count ()
"Show count of symbol at point."
@@ -514,6 +519,7 @@ BEG, END and LEN are the beginning, end and length of
changed text."
(unless (minibufferp)
(let* ((symbol (symbol-overlay-get-symbol))
(keyword (symbol-overlay-assoc symbol)))
+ (symbol-overlay-adjust-position)
(symbol-overlay-maybe-count keyword))))
;;;###autoload
@@ -523,7 +529,7 @@ When called interactively, then also reset
`symbol-overlay-keywords-alist'."
(interactive)
(unless (minibufferp)
- (mapc 'delete-overlay (symbol-overlay-get-list))
+ (mapc 'delete-overlay (symbol-overlay-get-list 0))
(when (called-interactively-p 'any)
(setq symbol-overlay-keywords-alist nil))))
@@ -547,7 +553,8 @@ When called interactively, then also reset
(keyword (symbol-overlay-assoc symbol)))
(if keyword
(let ((scope (not (cadr keyword))))
- (symbol-overlay-maybe-count (symbol-overlay-put-all symbol scope
keyword))
+ (symbol-overlay-maybe-count
+ (symbol-overlay-put-all symbol scope keyword))
(setq symbol-overlay-scope scope))
(setq symbol-overlay-scope (not symbol-overlay-scope))))))
@@ -573,7 +580,7 @@ KEYWORD provides the scope information."
(defun symbol-overlay-jump-call (jump-function dir)
"A general jumping process during which JUMP-FUNCTION is called to jump.
-DIR must be 1 or -1."
+DIR must be non-zero."
(unless (minibufferp)
(let* ((symbol (symbol-overlay-get-symbol))
(keyword (symbol-overlay-assoc symbol)))
@@ -584,7 +591,8 @@ DIR must be 1 or -1."
(symbol-overlay-maybe-count keyword)))))
(defun symbol-overlay-basic-jump (symbol dir)
- "Jump to SYMBOL's next location in the direction DIR. DIR must be 1 or -1."
+ "Jump to SYMBOL's next location in the direction DIR.
+DIR must be non-zero."
(let* ((case-fold-search nil)
(bounds (bounds-of-thing-at-point 'symbol))
(offset (- (point) (if (> dir 0) (cdr bounds) (car bounds))))
@@ -600,14 +608,36 @@ DIR must be 1 or -1."
(defun symbol-overlay-jump-next ()
"Jump to the next location of symbol at point."
(interactive)
+ (symbol-overlay-adjust-position)
(symbol-overlay-jump-call 'symbol-overlay-basic-jump 1))
;;;###autoload
(defun symbol-overlay-jump-prev ()
"Jump to the previous location of symbol at point."
(interactive)
+ (symbol-overlay-adjust-position)
(symbol-overlay-jump-call 'symbol-overlay-basic-jump -1))
+;;;###autoload
+(defun symbol-overlay-jump-first ()
+ "Jump to the first location."
+ (interactive)
+ (symbol-overlay-adjust-position)
+ (let* ((symbol (symbol-overlay-get-symbol))
+ (before (symbol-overlay-get-list -1 symbol))
+ (count (length before)))
+ (symbol-overlay-jump-call 'symbol-overlay-basic-jump (- count))))
+
+;;;###autoload
+(defun symbol-overlay-jump-last ()
+ "Jump to the last location."
+ (interactive)
+ (symbol-overlay-adjust-position)
+ (let* ((symbol (symbol-overlay-get-symbol))
+ (after (symbol-overlay-get-list 1 symbol))
+ (count (length after)))
+ (symbol-overlay-jump-call 'symbol-overlay-basic-jump (- count 1))))
+
(defvar-local symbol-overlay-definition-function
'(lambda (symbol) (concat "(?def[a-z-]* " symbol))
"An one-argument function that returns a regexp.")
@@ -638,7 +668,7 @@ with the input symbol."
DIR must be 1 or -1."
(unless (minibufferp)
(let* ((symbol (symbol-overlay-get-symbol nil t))
- (list (symbol-overlay-get-list symbol (if (> dir 0) 'cdr 'car) t)))
+ (list (symbol-overlay-get-list dir symbol t)))
(or list
(user-error (concat "No more "
(if (> dir 0) "forward" "backward")
- [nongnu] elpa/symbol-overlay 7ced9edc76 084/152: Merge pull request #16 from emacswatcher/master, (continued)
- [nongnu] elpa/symbol-overlay 7ced9edc76 084/152: Merge pull request #16 from emacswatcher/master, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 17cac32ea9 090/152: Added support to ignore keywords from c and c++ modes, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay b76f510037 089/152: little adjustment after merging, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay b6dba39f02 094/152: Merge pull request #24 from purcell/patch-4, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 2b565ba9ec 096/152: Fix error in symbol-overlay-ignore-function-python, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay d146404278 101/152: Bump version (fixes #19), ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay c630dbd5ce 105/152: Split code into sections, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 1fb712d4a8 114/152: typo fix, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay ff16ccf472 118/152: Merge pull request #44 from walseb/lisp-to-c-primitive, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 75c6ba66c0 116/152: Don't log navigation steps to *Messages* (fixes #37), ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay ad77d6cd1e 113/152: add symbol-overlay-jump-first/last,
ELPA Syncer <=
- [nongnu] elpa/symbol-overlay 8aa6b11a73 135/152: Maintain timer buffer-locally, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay eff8230ffe 119/152: Add a hook for when the cursor enters or leaves the symbol overlay, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay c41a347a0c 138/152: add symbol-overlay-ignore-function-clojure, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 2e79aaeae3 141/152: fixup! fixup! fixup! add symbol-overlay-ignore-function-clojure, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 6992e5e65c 111/152: add new var: symbol-overlay-displayed-window, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 8629a4ddbe 147/152: Merge pull request #76 from mattbeshara/cancel-timer-when-buffer-killed, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 4231a36e39 145/152: Merge pull request #73 from tarsiiformes/keyword, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay c439b73a5f 152/152: Merge pull request #78 from mattbeshara/single-active-timer, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 2ad907ae15 009/152: edit the descripition, ELPA Syncer, 2022/07/07
- [nongnu] elpa/symbol-overlay 50d645bc05 013/152: Merge branch 'syohex-fix-package', ELPA Syncer, 2022/07/07