Skip to content

Make the suggestions in the failure buffer interactive#29

Open
serycjon wants to merge 2 commits intotecosaur:masterfrom
serycjon:master
Open

Make the suggestions in the failure buffer interactive#29
serycjon wants to merge 2 commits intotecosaur:masterfrom
serycjon:master

Conversation

@serycjon
Copy link
Contributor

This addresses the issue #27, making the suggestions buffer interactive.
Now you can press RET on the suggested entries to open their definitions.

(let (suggestions last-match)
(while (setq last-match
(string-match "^[0-9]+)\\(.*\\)-->\\([A-Za-z]+\\)"
(string-match "^[0-9]+)\\(.*\\)-->\\(.*\\)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated fix of small annoyance - sometimes pressing 'q' did not bury the buffer, because killing the already dead buffer caused an error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant