Fix: (org-ql-find--snippet-*) Use save-excursion
This commit is contained in:
parent
06f1e1be6f
commit
6257ae8304
1 changed files with 20 additions and 18 deletions
|
|
@ -232,6 +232,7 @@ single predicate)."
|
||||||
(defun org-ql-find--snippet-simple (&optional _regexp)
|
(defun org-ql-find--snippet-simple (&optional _regexp)
|
||||||
"Return a snippet of the current entry.
|
"Return a snippet of the current entry.
|
||||||
Returns up to `org-ql-find-snippet-length' characters."
|
Returns up to `org-ql-find-snippet-length' characters."
|
||||||
|
(save-excursion
|
||||||
(org-end-of-meta-data t)
|
(org-end-of-meta-data t)
|
||||||
(unless (org-at-heading-p)
|
(unless (org-at-heading-p)
|
||||||
(let ((end (min (+ (point) org-ql-find-snippet-length)
|
(let ((end (min (+ (point) org-ql-find-snippet-length)
|
||||||
|
|
@ -240,12 +241,13 @@ Returns up to `org-ql-find-snippet-length' characters."
|
||||||
(truncate-string-to-width
|
(truncate-string-to-width
|
||||||
(replace-regexp-in-string "\n" " " (buffer-substring (point) end)
|
(replace-regexp-in-string "\n" " " (buffer-substring (point) end)
|
||||||
t t)
|
t t)
|
||||||
50 nil nil t)))))
|
50 nil nil t))))))
|
||||||
|
|
||||||
(defun org-ql-find--snippet-regexp (regexp)
|
(defun org-ql-find--snippet-regexp (regexp)
|
||||||
"Return a snippet of the current entry's matches for REGEXP."
|
"Return a snippet of the current entry's matches for REGEXP."
|
||||||
;; REGEXP may be nil if there are no qualifying tokens in the query.
|
;; REGEXP may be nil if there are no qualifying tokens in the query.
|
||||||
(when regexp
|
(when regexp
|
||||||
|
(save-excursion
|
||||||
(org-end-of-meta-data t)
|
(org-end-of-meta-data t)
|
||||||
(unless (org-at-heading-p)
|
(unless (org-at-heading-p)
|
||||||
(let* ((end (org-entry-end-position))
|
(let* ((end (org-entry-end-position))
|
||||||
|
|
@ -254,7 +256,7 @@ Returns up to `org-ql-find-snippet-length' characters."
|
||||||
do (goto-char (match-end 0)))))
|
do (goto-char (match-end 0)))))
|
||||||
(unless (string-empty-p snippets)
|
(unless (string-empty-p snippets)
|
||||||
(concat org-ql-find-snippet-prefix
|
(concat org-ql-find-snippet-prefix
|
||||||
(replace-regexp-in-string (rx (1+ "\n")) " " snippets t t)))))))
|
(replace-regexp-in-string (rx (1+ "\n")) " " snippets t t))))))))
|
||||||
|
|
||||||
(provide 'org-ql-find)
|
(provide 'org-ql-find)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue