20
20
(require 'cl-lib )
21
21
(require 'helm )
22
22
(require 'helm-help )
23
- (require 'ring )
24
23
25
24
26
25
(defgroup helm-font nil
93
92
(defvar helm-ucs--max-len nil )
94
93
(defvar helm-ucs--names nil )
95
94
(defvar helm-ucs-history nil )
96
- (defvar helm-ucs-recent ( make-ring helm-ucs-recent-size)
95
+ (defvar helm-ucs-recent nil
97
96
" Ring of recent `helm-ucs' selections." )
98
97
99
98
(defun helm-calculate-ucs-alist-max-len (names )
@@ -192,10 +191,17 @@ Where N=1 is the ucs code, N=2 the ucs char and N=3 the ucs name."
192
191
candidate)
193
192
(match-string n candidate)))
194
193
194
+ (defun helm-ucs-save-recentest (candidate )
195
+ (let ((lst (cons candidate (delete candidate helm-ucs-recent))))
196
+ (setq helm-ucs-recent
197
+ (if (> (length lst) helm-ucs-recent-size)
198
+ (nbutlast lst 1 )
199
+ lst))))
200
+
195
201
(defun helm-ucs-insert (candidate n )
196
202
" Insert the N part of CANDIDATE."
197
203
(with-helm-current-buffer
198
- (ring-remove+insert+extend helm-ucs-recent candidate)
204
+ (helm-ucs-save-recentest candidate)
199
205
(insert (helm-ucs-match candidate n))))
200
206
201
207
(defun helm-ucs-insert-char (candidate )
@@ -215,17 +221,17 @@ Where N=1 is the ucs code, N=2 the ucs char and N=3 the ucs name."
215
221
" Action that concatenate ucs marked chars."
216
222
(let ((marked (helm-marked-candidates)))
217
223
(cl-loop for candidate in marked
218
- do (ring-remove+insert+extend helm-ucs-recent candidate))
224
+ do (helm-ucs-save-recentest candidate))
219
225
(kill-new (mapconcat (lambda (x )
220
226
(helm-ucs-match x 2 ))
221
227
marked " " ))))
222
228
223
229
(defun helm-ucs-kill-code (candidate )
224
- (ring-remove+insert+extend helm-ucs-recent candidate)
230
+ (helm-ucs-save-recentest candidate)
225
231
(kill-new (helm-ucs-match candidate 1 )))
226
232
227
233
(defun helm-ucs-kill-name (candidate )
228
- (ring-remove+insert+extend helm-ucs-recent candidate)
234
+ (helm-ucs-save-recentest candidate)
229
235
(kill-new (helm-ucs-match candidate 3 )))
230
236
231
237
; ; Navigation in current-buffer (persistent)
@@ -276,7 +282,7 @@ Where N=1 is the ucs code, N=2 the ucs char and N=3 the ucs name."
276
282
(defvar helm-source-ucs-recent
277
283
(helm-build-sync-source " Recent UCS"
278
284
:action helm-ucs-actions
279
- :candidates (lambda () ( ring-elements helm-ucs-recent) )
285
+ :candidates (lambda () helm-ucs-recent)
280
286
:help-message helm-ucs-help-message
281
287
:keymap helm-ucs-map
282
288
:match-part (lambda (candidate ) (cadr (split-string candidate " :" )))
0 commit comments