File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,17 @@ Preserves pyimport text properties on LINE."
122
122
(eq major-mode mode))
123
123
(buffer-list )))
124
124
125
+ (defun pyimport--syntax-highlight (str )
126
+ " Apply font-lock properties to a string STR of Python code."
127
+ (with-temp-buffer
128
+ (insert str)
129
+ (delay-mode-hooks (python-mode ))
130
+ (if (fboundp 'font-lock-ensure )
131
+ (font-lock-ensure )
132
+ (with-no-warnings
133
+ (font-lock-fontify-buffer )))
134
+ (buffer-string )))
135
+
125
136
;;;### autoload
126
137
(defun pyimport-insert-missing (prefix )
127
138
" Try to insert an import for the symbol at point.
@@ -146,6 +157,10 @@ This is a simple heuristic: we just look for imports in all open Python buffers.
146
157
(setq matching-lines
147
158
(--map (pyimport--import-simplify it symbol) matching-lines))
148
159
160
+ ; ; Syntax highlight, to give a prettier choice in the minibuffer.
161
+ (setq matching-lines
162
+ (-map #'pyimport--syntax-highlight matching-lines))
163
+
149
164
; ; Sort by string length, because the shortest string is usually best.
150
165
(setq matching-lines
151
166
(--sort (< (length it) (length other)) matching-lines))
You can’t perform that action at this time.
0 commit comments