(?g elopher-get-image-node "im" ,elopher-image-face)
(?p elopher-get-image-node "im" ,elopher-image-face)
(?I elopher-get-image-node "im" ,elopher-image-face)
- (?4 elopher-get-binary-node "B" ,elopher-binary-face)
- (?9 elopher-get-binary-node "B" ,elopher-binary-face)
+ (?4 elopher-get-node-download "B" ,elopher-binary-face)
+ (?5 elopher-get-node-download "B" ,elopher-binary-face)
+ (?9 elopher-get-node-download "B" ,elopher-binary-face)
(?7 elopher-get-search-node "?" ,elopher-search-face)))
(defun elopher-insert-index-record (line)
;; Text retrieval
-(defvar elopher-url-regex "\\(https?\\|gopher\\)://\\([a-z.\-]+\\)\\(?3::[0-9]+\\)?\\(?4:/[^ \r\n\t(),]*\\)")
+(defvar elopher-url-regex "\\(https?\\|gopher\\)://\\([a-zA-Z0-9.\-]+\\)\\(?3::[0-9]+\\)?\\(?4:/[^ \r\n\t(),]*\\)")
(defun elopher-buttonify-urls (string)
"Turn substrings which look like urls in STRING into clickable buttons."
;; Search retrieval
(defun elopher-get-search-node ()
- (let* ((content (elopher-node-content elopher-current-node))
- (address (elopher-node-address elopher-current-node)))
+ (let ((content (elopher-node-content elopher-current-node))
+ (address (elopher-node-address elopher-current-node))
+ (aborted t))
(if content
(progn
(elopher-with-clean-buffer
- (insert content))
+ (insert content))
(elopher-restore-pos)
(message "Displaying cached search results. Reload to perform a new search."))
- (let* ((query-string (read-string "Query: "))
- (query-selector (concat (elopher-address-selector address) "\t" query-string))
- (search-address (elopher-make-address query-selector
- (elopher-address-host address)
- (elopher-address-port address))))
- (elopher-with-clean-buffer
- (insert "LOADING RESULTS..."))
- (elopher-get-selector search-address
- (lambda (proc event)
- (unless (string-prefix-p "deleted" event)
- (elopher-with-clean-buffer
- (elopher-insert-index elopher-selector-string))
- (goto-char (point-min))
- (elopher-set-node-content elopher-current-node
- (buffer-string)))))))))
+ (unwind-protect
+ (let* ((query-string (read-string "Query: "))
+ (query-selector (concat (elopher-address-selector address) "\t" query-string))
+ (search-address (elopher-make-address query-selector
+ (elopher-address-host address)
+ (elopher-address-port address))))
+ (setq aborted nil)
+ (elopher-with-clean-buffer
+ (insert "LOADING RESULTS..."))
+ (elopher-get-selector search-address
+ (lambda (proc event)
+ (unless (string-prefix-p "deleted" event)
+ (elopher-with-clean-buffer
+ (elopher-insert-index elopher-selector-string))
+ (goto-char (point-min))
+ (elopher-set-node-content elopher-current-node
+ (buffer-string))))))
+ (if aborted
+ (elopher-visit-parent-node))))))
;; Raw server response retrieval
(goto-char (point-min)))))
(message "Displaying raw server response. Reload to return to standard view."))
-
;; File export retrieval
(defvar elopher-download-filename)
(interactive)
(let ((button (button-at (point))))
(if button
- (elopher-visit-node (button-get button 'elopher-node)
- #'elopher-get-node-download)
+ (let ((node (button-get button 'elopher-node)))
+ (if node
+ (elopher-visit-node (button-get button 'elopher-node)
+ #'elopher-get-node-download)
+ (message "Can only download gopher links, not general URLs.")))
(message "No link selected."))))
-
;;; Mode and keymap
;;