@@ -153,35 +153,48 @@ These can have one of the following values
153
153
gitmojis-list))
154
154
155
155
(defun gitmoji-insert--action (x )
156
- (let ((utf8 (cadddr x))
157
- (shortcode (caddr x)))
158
- (if gitmoji--insert-utf8-emoji
159
- (insert-char utf8)
160
- (insert shortcode)))
161
- (insert " " ))
156
+ " Insert either Gitmoji's symbol or shortcode.
157
+ Based on the value of gitmoji--insert-utf8-emoji global variable,
158
+ followed by a space character.
159
+ It takes a single argument X, which is a list of selected Gitmoji's information."
160
+ (if x
161
+ (progn
162
+ (let ((utf8 (cadddr x))
163
+ (shortcode (caddr x)))
164
+ (if gitmoji--insert-utf8-emoji
165
+ (insert-char utf8)
166
+ (insert shortcode)))
167
+ (insert " " ))))
162
168
163
169
(defun gitmoji-insert-ivy ()
164
170
" Choose a gitmoji with ivy and insert it in the current buffer."
165
171
(interactive )
166
172
(let ((candidates (gitmoji-insert--candidates)))
167
- (ivy-read
168
- " Choose a gitmoji: "
169
- candidates
170
- :action #'gitmoji-insert--action
171
- )))
173
+ (condition-case nil
174
+ (ivy-read
175
+ " Choose a gitmoji: "
176
+ candidates
177
+ :action #'gitmoji-insert--action )
178
+ (quit nil ))))
172
179
173
180
(defun gitmoji-insert-helm ()
174
181
" Choose a gitmoji with helm and insert it in the current buffer."
175
182
(interactive )
176
- (helm :sources `((name . " Choose a gitmoji:" )
177
- (candidates . ,(gitmoji-insert--candidates))
178
- (action . (lambda (candidate ) (gitmoji-insert--action (append '(" " ) candidate)))))))
183
+ (condition-case nil
184
+ (helm :sources `((name . " Choose a gitmoji:" )
185
+ (candidates . ,(gitmoji-insert--candidates))
186
+ (action . (lambda (candidate ) (gitmoji-insert--action (append '(" " ) candidate))))))
187
+ (helm-quit nil )))
179
188
180
189
(defun gitmoji-insert-consult ()
181
190
" Choose a gitmoji with consult and insert it in the current buffer."
182
191
(interactive )
183
192
(let* ((candidates (gitmoji-insert--candidates))
184
- (candidate (assoc (completing-read " Choose a gitmoji: " candidates) candidates)))
193
+ (candidate (assoc
194
+ (condition-case nil
195
+ (completing-read " Choose a gitmoji: " candidates)
196
+ (quit nil ))
197
+ candidates)))
185
198
(gitmoji-insert--action candidate)))
186
199
187
200
(defun gitmoji-insert ()
@@ -191,8 +204,7 @@ These can have one of the following values
191
204
((and (memql 'ivy gitmoji-selection-backend) (featurep 'ivy )) (gitmoji-insert-ivy))
192
205
((and (memql 'helm gitmoji-selection-backend) (featurep 'helm )) (gitmoji-insert-helm))
193
206
((and (memql 'consult gitmoji-selection-backend) (featurep 'consult )) (gitmoji-insert-consult))
194
- (t (warn " No valid backend selected for Gitmoji." ))
195
- ))
207
+ (t (warn " No valid backend selected for Gitmoji." ))))
196
208
197
209
;;;### autoload
198
210
(define-minor-mode gitmoji-commit-mode
0 commit comments