Lisp HUG Maillist Archive

Accessing CLHS from dash(OSX) and velocity (Windows)

Hi,

Some time ago I've written about quite good tool called Dash which allows to open quickly multiple documentation on OSX, including CLHS, and my binding to LW IDE for OSX which allows quickly look-up in CLHS.
This tool has similar version on Windows, called Velocity.
If someone installs Velocity for Windows and CLHS docset in it, here is the code which allows to lookup the documentation on Windows with Velocity and OSX with Dash:

#+:mswindows
(fli:define-foreign-function (shell-execute "ShellExecute" :dbcs)
    ((hwnd fli-hwnd)
     (lp-operation :pointer)
     (lp-file :pointer)
     (lp-parameters :pointer)
     (lp-directory :pointer)
     (n-show-cmd :int32))
  :result-type (:unsigned :long)
  :documentation "Performs an operation on a specified file.")


(defun open-in-dash (name)
  (let ((url (concatenate 'string "dash://" name)))
    #+:mswindows
    (let ((null-ptr (fli:make-pointer :address 0 :type :void)))
      (fli:with-foreign-string (text element-count byte-count
                                     :external-format :unicode)
          url
        (declare (ignore element-count byte-count))
        (shell-execute 0 null-ptr text  null-ptr null-ptr 5)))
    #+:cocoa
    (objc:invoke (objc:invoke "NSWorkspace" "sharedWorkspace") "openURL:" (objc:invoke "NSURL" "URLWithString:" url))))


(editor:defcommand "Search In Dash" (p &optional name)
     "Search current word in Dash"
     "Search current word in Dash"
  (let* ((name (format nil "~a" (editor:get-symbol-from-point (editor:current-point)))))
    (open-in-dash name)))

(editor:bind-key "Search In Dash" "Ctrl-F1" :global)


Hope it will be useful for some.

Br
/Alexey

Updated at: 2020-12-10 08:30 UTC