refactor: Code tidying
This commit is contained in:
@@ -28,7 +28,7 @@ string.")
|
||||
(defvar syd-lookup-documentation-handlers '(syd-lookup-online-documentation)
|
||||
"A list of lookup handlers used to find documentation. A lookup handler
|
||||
receives an identifier, and is expected to return nil on failure, and non-nil on
|
||||
success. The specific return value is unused outside of the test for nil.")
|
||||
success. When a handler returns a marker, the marker will be jumped to.")
|
||||
|
||||
(defun syd-lookup--prompt-for-online-backend ()
|
||||
(assoc-string
|
||||
@@ -46,7 +46,7 @@ success. The specific return value is unused outside of the test for nil.")
|
||||
((stringp backend-fn)
|
||||
(browse-url (format backend-fn
|
||||
(url-encode-url
|
||||
(read-string (format "Search for (on %s): "
|
||||
(read-string (format "Search %s for: "
|
||||
name)
|
||||
query-string)))))
|
||||
(t (signal 'wrong-type-argument `("backend" ,backend-fn))))))
|
||||
@@ -56,18 +56,17 @@ success. The specific return value is unused outside of the test for nil.")
|
||||
(interactive (list (syd-lookup--prompt-for-online-backend)
|
||||
:query-string (when (use-region-p)
|
||||
(syd-thing-at-point-or-region))))
|
||||
(syd-lookup--call-online-backend (syd-lookup--prompt-for-online-backend)
|
||||
(syd-lookup--call-online-backend backend
|
||||
:query-string query-string))
|
||||
|
||||
;;;###autoload
|
||||
(defun syd-lookup-documentation (identifier)
|
||||
"Try to find documentation on IDENTIFIER, and "
|
||||
(interactive (list (syd-thing-at-point-or-region)))
|
||||
(if-let ((r (syd-lookup--jump-to 'documentation identifier
|
||||
:display-fn #'pop-to-buffer)))
|
||||
r
|
||||
((user-error "Couldn't find documentation on %S"
|
||||
(substring-no-properties identifier)))))
|
||||
(or (syd-lookup--jump-to 'documentation identifier
|
||||
:display-fn #'pop-to-buffer)
|
||||
(user-error "Couldn't find documentation on %S"
|
||||
(substring-no-properties identifier))))
|
||||
|
||||
(defvar syd-lookup--handlers-by-category
|
||||
'((documentation . syd-lookup-documentation-handlers)))
|
||||
@@ -80,7 +79,6 @@ success. The specific return value is unused outside of the test for nil.")
|
||||
;; handler.
|
||||
(result (run-hook-wrapped handlers #'syd-lookup--run-handler
|
||||
identifier origin)))
|
||||
(message "result wrap hok: %S" result)
|
||||
(unwind-protect
|
||||
(when (cond ((null result)
|
||||
(message "No lookup handler could find %S" identifier)
|
||||
@@ -105,7 +103,6 @@ success. The specific return value is unused outside of the test for nil.")
|
||||
(error
|
||||
(message "Lookup handler %S threw an error: %s" handler e)
|
||||
'fail))))
|
||||
(message "result %S" result)
|
||||
(cond ((eq result 'fail)
|
||||
(set-window-configuration wconf)
|
||||
nil)
|
||||
|
||||
Reference in New Issue
Block a user