Fixed search getter.
[elpher.git] / elopher.el
index 217ef98..ba5fb17 100644 (file)
@@ -306,7 +306,7 @@ The result is stored as a string in the variable elopher-selector-string."
 
 ;; 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."
@@ -400,8 +400,9 @@ The result is stored as a string in the variable elopher-selector-string."
 ;; 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
@@ -414,6 +415,7 @@ The result is stored as a string in the variable elopher-selector-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
@@ -424,7 +426,8 @@ The result is stored as a string in the variable elopher-selector-string."
                                       (goto-char (point-min))
                                       (elopher-set-node-content elopher-current-node
                                                                 (buffer-string))))))
-        (elopher-visit-parent-node)))))
+        (if aborted
+            (elopher-visit-parent-node))))))
 
 ;; Raw server response retrieval
 
@@ -532,11 +535,13 @@ The result is stored as a string in the variable elopher-selector-string."
   (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
 ;;