Skip to content

Commit

Permalink
fix(core): avoid thing-at-point errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Dec 6, 2023
1 parent bc51ebf commit 0a0dac7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/me-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -1062,10 +1062,15 @@ by `+screenshot-delay') before taking the screenshot."

(defun +region-or-thing-at-point ()
"Return the region or the thing at point."
(when-let ((thing (or (prog1 (thing-at-point 'region t)
(deactivate-mark))
(cl-some (+apply-partially-right #'thing-at-point t)
'(symbol email number string word)))))
(when-let ((thing (condition-case nil
(or (prog1 (thing-at-point 'region t)
(deactivate-mark))
(cl-some (+apply-partially-right #'thing-at-point t)
'(symbol email number string word)))
;; Sometimes, specially when in an empty buffer,
;; `thing-at-point' can raise an error, in this case, lets just
;; start with an empty string
(error ""))))
;; If the matching thing has multi-lines, join them
(string-join (string-lines thing))))

Expand Down

0 comments on commit 0a0dac7

Please sign in to comment.