[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/el-search c878a24 173/332: Fix "Make amount of context
From: |
Stefan Monnier |
Subject: |
[elpa] externals/el-search c878a24 173/332: Fix "Make amount of context around occur matches adjustable" |
Date: |
Tue, 1 Dec 2020 15:48:38 -0500 (EST) |
branch: externals/el-search
commit c878a24481904b1e24d7b4f38b71b3e84be502e6
Author: Michael Heerdegen <michael_heerdegen@web.de>
Commit: Michael Heerdegen <michael_heerdegen@web.de>
Fix "Make amount of context around occur matches adjustable"
Add missing defun `el-search--bounds-of-defun'.
---
el-search.el | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/el-search.el b/el-search.el
index f1dd8b4..1298e32 100644
--- a/el-search.el
+++ b/el-search.el
@@ -503,6 +503,42 @@ The non-nil value should be one of the symbols `forward'
and
"Ignore the arguments and return t."
t)
+(defun el-search--bounds-of-defun (&optional pos)
+ "Return (BEG . END) of the top level s-exp covering POS.
+POS defaults to point. If no sexp is covering POS, return
+nil."
+ (cl-callf or pos (point))
+ (save-restriction
+ (widen)
+ (let (defun-beg defun-end)
+ (cl-flet ((top-level-paren-start
+ (pos)
+ (save-excursion
+ (let ((syntax-at-pos (syntax-ppss pos)))
+ (and (not (zerop (nth 0 syntax-at-pos)))
+ (syntax-ppss-toplevel-pos syntax-at-pos))))))
+ (if (setq defun-beg
+ (or
+ ;; Iff inside a top-level paren group, this returns the
defun beginning
+ (top-level-paren-start pos)
+ ;; Iff at the beginning top-level paren group, this
succeeds and returns point
+ (and (not (eobp)) (top-level-paren-start (1+ pos)))))
+ (cons defun-beg (scan-sexps defun-beg 1))
+ ;; This corner case (not inside any s-exp or current top level s-exp
+ ;; not a list) is a bit hairy to do with syntax stuff, so let's just
+ ;; use el-search:
+ (save-excursion
+ (goto-char (point-min))
+ (setq defun-beg (point-min))
+ (setq defun-end (point-min))
+ (while (and (<= defun-end pos)
+ (el-search-forward '_ nil t))
+ (setq defun-beg (point))
+ (goto-char (setq defun-end (el-search--end-of-sexp))))
+ (if (<= defun-beg pos defun-end)
+ (cons defun-beg defun-end)
+ nil)))))))
+
(defun el-search-with-short-term-memory (function)
"Wrap FUNCTION to cache the last arguments/result pair."
(let ((cached nil))
- [elpa] externals/el-search a38665c 115/332: Add section "Patterns for stylistic rewriting" and pattern `iffy-if', (continued)
- [elpa] externals/el-search a38665c 115/332: Add section "Patterns for stylistic rewriting" and pattern `iffy-if', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8fdb91d 124/332: New command `el-search-load-path', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 4202501 148/332: el-search version 1.3: Lots of fixes and improvements, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search d54491c 147/332: Add a FILE argument to `el-search-dired-marked-files', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search a26b6e0 152/332: Reset wrap flag even when no match, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6919e8d 141/332: Also count pattern types starting with "_" as internal, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b8e3812 144/332: Improve half-baked introduction of key bindings, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search e96c054 156/332: Handle read errors when reading and validating replacement, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6f0f22c 155/332: Some details, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 6e6013a 159/332: Fix and speed up the `change' pattern type, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c878a24 173/332: Fix "Make amount of context around occur matches adjustable",
Stefan Monnier <=
- [elpa] externals/el-search f6b1aec 180/332: Some details, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8583d46 191/332: Fix resuming a single-buffer query-replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 365f93f 197/332: * el-search/el-search.el: Some buffer display related minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c69dd52 205/332: * el-search/el-search.el: Some minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search c41288f 208/332: Make el-search key binding installation more flexible, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8d20f8a 217/332: Add face `el-search-highlight-in-prompt-face', Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 75f94f9 218/332: Improve quit/error handling in el-search-query-replace, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search b278fb7 219/332: Update a variable when splicing mode is toggled, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 8175417 237/332: * el-search/el-search.el: More minor tweaks, Stefan Monnier, 2020/12/01
- [elpa] externals/el-search 1f81442 241/332: [el-search] Improve forward search functions, Stefan Monnier, 2020/12/01