mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-24 03:50:24 +10:00
Minor updates.
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
- [[#associating-lookup-handlers-with-major-modes][Associating lookup handlers with major modes]]
|
||||
- [[#associating-dash-docsets-with-major-modes][Associating Dash docsets with major modes]]
|
||||
- [[#open-in-eww-instead-of-browser][Open in eww instead of browser]]
|
||||
- [[#open-in-xwidget-webkit-instead-of-browser][Open in Xwidget WebKit instead of browser]]
|
||||
- [[#appendix][Appendix]]
|
||||
- [[#commands][Commands]]
|
||||
|
||||
@@ -40,7 +41,6 @@ or synonyms.
|
||||
+ ~+dictionary~ Enable word definition and thesaurus lookup functionality.
|
||||
+ ~+offline~ Install and prefer offline dictionary/thesaurus.
|
||||
+ ~+docsets~ Enable integration with Dash.app docsets.
|
||||
+ ~+xwidget~ Enable integration with [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Embedded-WebKit-Widgets.html][Embedded Webkit Widgets]].
|
||||
|
||||
** Plugins
|
||||
+ [[https://github.com/jacktasia/dumb-jump][dumb-jump]]
|
||||
@@ -208,13 +208,23 @@ This determines what docsets to implicitly search for when you use
|
||||
docsets must be installed with ~+lookup/install-docset~.
|
||||
|
||||
** Open in eww instead of browser
|
||||
To open results from ~+lookup/online~ in EWW instead of your system browser,
|
||||
change ~+lookup-open-url-fn~ (default: ~#'browse-url~):
|
||||
To open results from ~+lookup/online~ or ~+lookup/in-docsets~ in EWW instead
|
||||
of your system browser, change ~+lookup-open-url-fn~ (default:
|
||||
~#'browse-url~):
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq +lookup-open-url-fn #'eww)
|
||||
#+END_SRC
|
||||
|
||||
** Open in Xwidget WebKit instead of browser
|
||||
To open results from ~+lookup/online~ or ~+lookup/in-docsets~ in Xwidget
|
||||
WebKit instead of your system browser, set ~+lookup-open-url-fn~ to
|
||||
~+lookup-xwidget-webkit-open-url-fn~ (needs Emacs with Xwidgets support):
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq +lookup-open-url-fn #'+lookup-xwidget-webkit-open-url-fn)
|
||||
#+END_SRC
|
||||
|
||||
* Appendix
|
||||
** Commands
|
||||
+ ~+lookup/definition~
|
||||
|
||||
@@ -192,6 +192,18 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g.
|
||||
'deferred
|
||||
t))))
|
||||
|
||||
(defun +lookup-dictionary-definition-backend-fn (identifier)
|
||||
"Look up dictionary definition for IDENTIFIER."
|
||||
(when (derived-mode-p 'text-mode)
|
||||
(+lookup/dictionary-definition identifier)
|
||||
'deferred))
|
||||
|
||||
(defun +lookup-thesaurus-definition-backend-fn (identifier)
|
||||
"Look up synonyms for IDENTIFIER."
|
||||
(when (derived-mode-p 'text-mode)
|
||||
(+lookup/synonyms identifier)
|
||||
'deferred))
|
||||
|
||||
(defun +lookup-xref-definitions-backend-fn (identifier)
|
||||
"Non-interactive wrapper for `xref-find-definitions'"
|
||||
(+lookup--xref-show 'xref-backend-definitions identifier #'xref--show-defs))
|
||||
@@ -343,7 +355,7 @@ Otherwise, falls back on `find-file-at-point'."
|
||||
(list (or (doom-thing-at-point-or-region 'word)
|
||||
(read-string "Look up in dictionary: "))
|
||||
current-prefix-arg))
|
||||
(message "Looking up definition for %S" identifier)
|
||||
(message "Looking up dictionary definition for %S" identifier)
|
||||
(cond ((and IS-MAC (require 'osx-dictionary nil t))
|
||||
(osx-dictionary--view-result identifier))
|
||||
((and +lookup-dictionary-prefer-offline
|
||||
|
||||
@@ -16,24 +16,23 @@
|
||||
|
||||
;;;###autoload
|
||||
(defun +lookup-online-backend-fn (identifier)
|
||||
"Opens the browser and searches for IDENTIFIER online.
|
||||
|
||||
Will prompt for which search engine to use the first time (or if the universal
|
||||
argument is non-nil)."
|
||||
"Open the browser and search for IDENTIFIER online.
|
||||
When called for the first time, or with a non-nil prefix argument, prompt for
|
||||
the search engine to use."
|
||||
(+lookup/online
|
||||
identifier
|
||||
(+lookup--online-provider (not current-prefix-arg))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +lookup/online (query provider)
|
||||
"Looks up QUERY (a string) in you browser usin PROVIDER.
|
||||
"Look up QUERY in the browser using PROVIDER.
|
||||
When called interactively, prompt for a query and, when called for the first
|
||||
time, the provider from `+lookup-provider-url-alist'. In subsequent calls, reuse
|
||||
the previous provider. With a non-nil prefix argument, always prompt for the
|
||||
provider.
|
||||
|
||||
PROVIDER should be a key of `+lookup-provider-url-alist'.
|
||||
|
||||
When used interactively, it will prompt for a query and, for the first time, the
|
||||
provider from `+lookup-provider-url-alist'. On consecutive uses, the last
|
||||
provider will be reused. If the universal argument is supplied, always prompt
|
||||
for the provider."
|
||||
QUERY must be a string, and PROVIDER must be a key of
|
||||
`+lookup-provider-url-alist'."
|
||||
(interactive
|
||||
(list (if (use-region-p) (doom-thing-at-point-or-region))
|
||||
(+lookup--online-provider current-prefix-arg)))
|
||||
@@ -64,7 +63,7 @@ for the provider."
|
||||
|
||||
;;;###autoload
|
||||
(defun +lookup/online-select ()
|
||||
"Runs `+lookup/online', but always prompts for the provider to use."
|
||||
"Run `+lookup/online', but always prompt for the provider to use."
|
||||
(interactive)
|
||||
(let ((current-prefix-arg t))
|
||||
(call-interactively #'+lookup/online)))
|
||||
@@ -77,7 +76,7 @@ for the provider."
|
||||
(defvar counsel-search-engine)
|
||||
;;;###autoload
|
||||
(defun +lookup--online-backend-google (query)
|
||||
"Search google, starting with QUERY, with live autocompletion."
|
||||
"Search Google, starting with QUERY, with live autocompletion."
|
||||
(cond ((fboundp 'counsel-search)
|
||||
(let ((ivy-initial-inputs-alist `((t . ,query)))
|
||||
(counsel-search-engine 'google))
|
||||
@@ -91,7 +90,7 @@ for the provider."
|
||||
|
||||
;;;###autoload
|
||||
(defun +lookup--online-backend-duckduckgo (query)
|
||||
"Search duckduckgo, starting with QUERY, with live autocompletion."
|
||||
"Search DuckDuckGo, starting with QUERY, with live autocompletion."
|
||||
(cond ((fboundp 'counsel-search)
|
||||
(let ((ivy-initial-inputs-alist `((t . ,query)))
|
||||
(counsel-search-engine 'ddg))
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
("Wolfram alpha" "https://wolframalpha.com/input/?i=%s")
|
||||
("Wikipedia" "https://wikipedia.org/search-redirect.php?language=en&go=Go&search=%s"))
|
||||
(when (featurep! :lang rust)
|
||||
'(("Rust Docs" "https://doc.rust-lang.org/edition-guide/?search=%s"))))
|
||||
'(("Rust Docs" "https://doc.rust-lang.org/std/?search=%s"))))
|
||||
"An alist that maps online resources to either:
|
||||
|
||||
1. A search url (needs on '%s' to substitute with an url encoded query),
|
||||
@@ -41,7 +41,8 @@ Used by `+lookup/online'.")
|
||||
"Function to use to open search urls.")
|
||||
|
||||
(defvar +lookup-definition-functions
|
||||
'(+lookup-xref-definitions-backend-fn
|
||||
'(+lookup-dictionary-definition-backend-fn
|
||||
+lookup-xref-definitions-backend-fn
|
||||
+lookup-dumb-jump-backend-fn
|
||||
+lookup-project-search-backend-fn
|
||||
+lookup-evil-goto-definition-backend-fn)
|
||||
@@ -73,7 +74,8 @@ argument: the identifier at point. See `set-lookup-handlers!' about adding to
|
||||
this list.")
|
||||
|
||||
(defvar +lookup-references-functions
|
||||
'(+lookup-xref-references-backend-fn
|
||||
'(+lookup-thesaurus-definition-backend-fn
|
||||
+lookup-xref-references-backend-fn
|
||||
+lookup-project-search-backend-fn)
|
||||
"Functions for `+lookup/references' to try, before resorting to `dumb-jump'.
|
||||
Stops at the first function to return non-nil or change the current
|
||||
@@ -116,8 +118,6 @@ Used by `+lookup/dictionary-definition' and `+lookup/synonyms'.
|
||||
For `+lookup/dictionary-definition', this is ignored on Mac, where Emacs users
|
||||
Dictionary.app behind the scenes to get definitions.")
|
||||
|
||||
(defvar +lookup--dash-docs-xwidget-webkit-last-session-buffer nil)
|
||||
|
||||
|
||||
;;
|
||||
;;; dumb-jump
|
||||
@@ -186,34 +186,6 @@ Dictionary.app behind the scenes to get definitions.")
|
||||
dash-docs-min-length 2
|
||||
dash-docs-browser-func #'eww)
|
||||
|
||||
;; Before `gnutls' is loaded, `gnutls-algorithm-priority' is treated as a
|
||||
;; lexical variable, which breaks `+lookup*fix-gnutls-error'
|
||||
(defvar gnutls-algorithm-priority)
|
||||
(defadvice! +lookup--fix-gnutls-error-a (orig-fn url)
|
||||
"Fixes integer-or-marker-p errors emitted from Emacs' url library,
|
||||
particularly, the `url-retrieve-synchronously' call in
|
||||
`dash-docs-read-json-from-url'. This is part of a systemic issue with Emacs 26's
|
||||
networking library (fixed in Emacs 27+, apparently).
|
||||
|
||||
See https://github.com/magit/ghub/issues/81"
|
||||
:around #'dash-docs-read-json-from-url
|
||||
(let ((gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3"))
|
||||
(funcall orig-fn url)))
|
||||
|
||||
;; Dash docset + Xwidget integration
|
||||
(when (featurep! +xwidget)
|
||||
(defun +lookup-dash-docs-xwidget-webkit-browse-url-fn (url &optional new-session)
|
||||
(if (not (display-graphic-p))
|
||||
(eww url new-session)
|
||||
(setq xwidget-webkit-last-session-buffer +lookup--dash-docs-xwidget-webkit-last-session-buffer)
|
||||
(save-window-excursion
|
||||
(xwidget-webkit-browse-url url new-session))
|
||||
(with-popup-rules! '(("^\\*xwidget" :vslot -11 :size 0.35 :select nil))
|
||||
(pop-to-buffer xwidget-webkit-last-session-buffer))
|
||||
(setq +lookup--dash-docs-xwidget-webkit-last-session-buffer xwidget-webkit-last-session-buffer
|
||||
xwidget-webkit-last-session-buffer nil)))
|
||||
(setq dash-docs-browser-func #'+lookup-dash-docs-xwidget-webkit-browse-url-fn))
|
||||
|
||||
(cond ((featurep! :completion helm)
|
||||
(require 'helm-dash nil t))
|
||||
((featurep! :completion ivy)
|
||||
@@ -233,11 +205,5 @@ See https://github.com/magit/ghub/issues/81"
|
||||
collect (cons service #'+eval-display-results-in-popup))))
|
||||
|
||||
|
||||
(when (featurep! +dictionary)
|
||||
(define-key! text-mode-map
|
||||
[remap +lookup/definition] #'+lookup/dictionary-definition
|
||||
[remap +lookup/references] #'+lookup/synonyms))
|
||||
|
||||
|
||||
;;;###package synosaurus
|
||||
(setq synosaurus-choose-method 'default) ; use ivy/helm instead of ido
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
(package! helm))
|
||||
|
||||
;;
|
||||
(package! dumb-jump :pin "d86f59c4c0eb9371dd84bc2aaff5d7445f04ba27")
|
||||
(package! dumb-jump :pin "b81573184c97fbc6181d0a4fe408caa23c0d621b")
|
||||
(when (featurep! :completion ivy)
|
||||
(package! ivy-xref :pin "3d4c35fe2b243d948d8fe02a1f0d76a249d63de9"))
|
||||
(when (featurep! :completion helm)
|
||||
(package! helm-xref :pin "6b4a8bd91f5eaf82f51bd31b03f6587387fe6983"))
|
||||
|
||||
;; For dictionary and online lookup
|
||||
(package! request :pin "912525c772984c6af0fd84acd6699ee43d91037a")
|
||||
(package! request :pin "d02d1347ffdf138cffd380cbeac62ac8732036ef")
|
||||
|
||||
(when (featurep! +docsets)
|
||||
(package! dash-docs :pin "dafc8fc9f1ddb2e4e39e0b8d066c42d5d7ce8d06")
|
||||
@@ -28,11 +28,7 @@
|
||||
(if IS-MAC
|
||||
(package! osx-dictionary :pin "1b79ff64c72485cb078db9ab7ee3256b11a99f4b")
|
||||
(package! define-word :pin "08c71b1ff4fd07bf0c78d1fcf77efeaafc8f7443")
|
||||
;; HACK Fix #2945: the main package is broken due to
|
||||
;; SavchenkoValeriy/emacs-powerthesaurus#11
|
||||
(package! powerthesaurus
|
||||
:recipe (:host github :repo "maxchaos/emacs-powerthesaurus" :branch "pt-api-change")
|
||||
:pin "4a834782a394f2dc70fc02d68b6962b44d87f0cf")
|
||||
(package! powerthesaurus :pin "93036d3b111925ebc34f747ff846cb0b8669b92e")
|
||||
(when (featurep! +offline)
|
||||
(package! wordnut :pin "feac531404041855312c1a046bde7ea18c674915")
|
||||
(package! synosaurus :pin "14d34fc92a77c3a916b4d58400424c44ae99cd81"))))
|
||||
|
||||
Reference in New Issue
Block a user