256 |
|
|
257 |
;; Main code: |
;; Main code: |
258 |
|
|
259 |
(defun* quickurl-read (&optional (buffer (current-buffer))) |
(defun* quickurl-read (&optional buffer) |
260 |
"`read' the URL list from BUFFER into `quickurl-urls'. |
"`read' the URL list from BUFFER into `quickurl-urls'. |
261 |
|
|
262 |
|
BUFFER, if nil, defaults to current buffer. |
263 |
Note that this function moves point to `point-min' before doing the `read' |
Note that this function moves point to `point-min' before doing the `read' |
264 |
It also restores point after the `read'." |
It also restores point after the `read'." |
265 |
(save-excursion |
(save-excursion |
266 |
(setf (point) (point-min)) |
(setf (point) (point-min)) |
267 |
(setq quickurl-urls (funcall quickurl-sort-function (read buffer))))) |
(setq quickurl-urls (funcall quickurl-sort-function |
268 |
|
(read (or buffer (current-buffer))))))) |
269 |
|
|
270 |
(defun quickurl-load-urls () |
(defun quickurl-load-urls () |
271 |
"Load the contents of `quickurl-url-file' into `quickurl-urls'." |
"Load the contents of `quickurl-url-file' into `quickurl-urls'." |
300 |
(message "Found %s" (quickurl-url-url url)))) |
(message "Found %s" (quickurl-url-url url)))) |
301 |
|
|
302 |
;;;###autoload |
;;;###autoload |
303 |
(defun* quickurl (&optional (lookup (funcall quickurl-grab-lookup-function))) |
(defun* quickurl (&optional lookup) |
304 |
"Insert an URL based on LOOKUP. |
"Insert an URL based on LOOKUP. |
305 |
|
|
306 |
If not supplied LOOKUP is taken to be the word at point in the current |
If not supplied LOOKUP is taken to be the word at point in the current |
307 |
buffer, this default action can be modifed via |
buffer, this default action can be modifed via |
308 |
`quickurl-grab-lookup-function'." |
`quickurl-grab-lookup-function'." |
309 |
(interactive) |
(interactive) |
310 |
(when lookup |
(when (or lookup |
311 |
|
(setq lookup (funcall quickurl-grab-lookup-function))) |
312 |
(quickurl-load-urls) |
(quickurl-load-urls) |
313 |
(let ((url (quickurl-find-url lookup))) |
(let ((url (quickurl-find-url lookup))) |
314 |
(if (null url) |
(if (null url) |
395 |
(message "Added %s" url)))))) |
(message "Added %s" url)))))) |
396 |
|
|
397 |
;;;###autoload |
;;;###autoload |
398 |
(defun* quickurl-browse-url (&optional (lookup (funcall quickurl-grab-lookup-function))) |
(defun quickurl-browse-url (&optional lookup) |
399 |
"Browse the URL associated with LOOKUP. |
"Browse the URL associated with LOOKUP. |
400 |
|
|
401 |
If not supplied LOOKUP is taken to be the word at point in the |
If not supplied LOOKUP is taken to be the word at point in the |
402 |
current buffer, this default action can be modifed via |
current buffer, this default action can be modifed via |
403 |
`quickurl-grab-lookup-function'." |
`quickurl-grab-lookup-function'." |
404 |
(interactive) |
(interactive) |
405 |
(when lookup |
(when (or lookup |
406 |
|
(setq lookup (funcall quickurl-grab-lookup-function))) |
407 |
(quickurl-load-urls) |
(quickurl-load-urls) |
408 |
(let ((url (quickurl-find-url lookup))) |
(let ((url (quickurl-find-url lookup))) |
409 |
(if url |
(if url |