Skip to content

Commit

Permalink
Add a function to extract candidate
Browse files Browse the repository at this point in the history
and simplify regexp as well.
  • Loading branch information
thierryvolpiatto committed Dec 21, 2024
1 parent fefacdd commit e9af474
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions helm-dictionary.el
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,18 @@ browser in `helm-browse-url-default-browser-alist'"
(cons l1term l2term)))))


(defun helm-dictionary-get-candidate (entry term)
(replace-regexp-in-string
" *[[{].+[]}]" ""
(helm-acase term
(1 (car entry))
(2 (cdr entry)))))

(defun helm-dictionary-insert-l1term (entry)
(insert
(replace-regexp-in-string
" *{.+}\\| *\\[.+\\]" "" (car entry))))
(insert (helm-dictionary-get-candidate entry 1)))

(defun helm-dictionary-insert-l2term (entry)
(insert
(replace-regexp-in-string
" *{.+}\\| *\\[.+\\]" "" (cdr entry))))
(insert (helm-dictionary-get-candidate entry 2)))

(defun helm-dictionary-build (name file)
(helm-build-in-file-source name file
Expand Down

0 comments on commit e9af474

Please sign in to comment.