Make the suggestions in the failure buffer interactive#29
Make the suggestions in the failure buffer interactive#29serycjon wants to merge 2 commits intotecosaur:masterfrom
Conversation
| (let (suggestions last-match) | ||
| (while (setq last-match | ||
| (string-match "^[0-9]+)\\(.*\\)-->\\([A-Za-z]+\\)" | ||
| (string-match "^[0-9]+)\\(.*\\)-->\\(.*\\)" |
There was a problem hiding this comment.
This makes sure to include the whole suggestion, so that it can be searched.
For example when searching for "project" in the "Online Etymology Dictionary", it returns two suggestions:
- project (n.)
- project (v.)
allowing only alpha characters would not work
| (list (append (cadr (assoc dict suggestions)) (list word)))) | ||
| (setq suggestions (append suggestions `((,dict . ((,word))))))))) | ||
| (concat | ||
| "\u200B" |
There was a problem hiding this comment.
a hack(?) to make sure that the point does not get before the first heading (which makes outline navigation not work)
| (format "\u200B\u200B%s" entry) | ||
| ;; (mapconcat #'identity (cadr dict-suggestions) "\n\u200B\u200B\u200B") | ||
| 'face 'font-lock-keyword-face | ||
| 'keymap (let ((map (make-sparse-keymap))) |
There was a problem hiding this comment.
The main part - propertizing the entry with keymap.
| (lambda () | ||
| (interactive) | ||
| (lexic-search entry nil (list (car dict-suggestions)) t) | ||
| (setq lexic-current-dictionary-list t))) |
There was a problem hiding this comment.
A hack(?) to reset the lexic-current-dictionary-list. Without this, lexic remembers the particular dictionary until called with prefix argument.
Not specifying the dict-list argument of lexic-search results in the "suggestions" buffer again.
| "Bury lexic buffer and restore the previous window configuration." | ||
| (interactive) | ||
| (kill-process (get-process lexic-process-name)) | ||
| (ignore-errors (kill-process (get-process lexic-process-name))) |
There was a problem hiding this comment.
unrelated fix of small annoyance - sometimes pressing 'q' did not bury the buffer, because killing the already dead buffer caused an error
This addresses the issue #27, making the suggestions buffer interactive.
Now you can press RET on the suggested entries to open their definitions.