Skip to content

Commit 8e1792b

Browse files
committed
Fail gracefully if there's no symbol at point
1 parent c0c12b6 commit 8e1792b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pyimport.el

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,12 @@ baz is SYMBOL."
122122
"Try to insert an import for the symbol at point.
123123
Dumb: just scans open Python buffers."
124124
(interactive)
125-
(let ((symbol (substring-no-properties (thing-at-point 'symbol)))
125+
(let ((symbol (thing-at-point 'symbol))
126126
(matching-lines nil)
127127
(case-fold-search nil))
128+
(unless symbol
129+
(user-error "No symbol at point"))
130+
(setq symbol (substring-no-properties symbol))
128131
;; Find all the import lines in all Python buffers
129132
(dolist (buffer (pyimport--buffers-in-mode 'python-mode))
130133
(dolist (line (pyimport--import-lines buffer))

0 commit comments

Comments
 (0)