X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=elpher.git;a=blobdiff_plain;f=elpher.el;h=39e32a2d4a3e06a9443b5a6634411338892ef15c;hp=651318daab625cb292cef5d33953935c8bfc78c2;hb=6d80df84e2c13ffad263ec444ac724e7ec17735c;hpb=befa575d2a89dbee6c30443cced03b0ef89977b4 diff --git a/elpher.el b/elpher.el index 651318d..39e32a2 100644 --- a/elpher.el +++ b/elpher.el @@ -225,6 +225,11 @@ Otherwise, \\[elpher-show-bookmarks] will visit a special elpher bookmark page within which all of the standard elpher keybindings are active." :type '(boolean)) +(defcustom elpher-start-page "about:welcome" + "Specify the page displayed initially by elpher. +The default welcome screen \"about:welcome\", while the bookmarks list +is \"about:bookmarks\". You can also specify local files via \"file:\".") + ;; Face customizations (defgroup elpher-faces nil @@ -385,9 +390,7 @@ requiring gopher-over-TLS." (defun elpher-address-to-url (address) "Get string representation of ADDRESS, or nil if ADDRESS is special." - (if (elpher-address-special-p address) - nil - (url-encode-url (url-recreate-url address)))) + (url-encode-url (url-recreate-url address))) (defun elpher-address-type (address) "Retrieve type of ADDRESS object. @@ -410,10 +413,7 @@ address refers to, via the table `elpher-type-map'." (defun elpher-address-special-p (address) "Return non-nil if ADDRESS is a special address." - (let ((type (url-type address))) - (and type - (listp type) - (eq (car type) 'special)))) + (pcase (elpher-address-type address) (`(special ,subtype) t))) (defun elpher-address-protocol (address) "Retrieve the transport protocol for ADDRESS. This is nil for special addresses." @@ -482,10 +482,10 @@ If no address is defined, returns 0. (This is for compatibility with the URL li "Create a page with DISPLAY-STRING and ADDRESS." (list display-string address)) -(defun elpher-make-welcome-page () +(defun elpher-make-start-page () "Create the welcome page." - (elpher-make-page "Elpher Welcome Page" - (elpher-make-special-address 'welcome))) + (elpher-make-page "Start Page" + (elpher-address-from-url elpher-start-page))) (defun elpher-page-display-string (page) "Retrieve the display string corresponding to PAGE." @@ -2138,7 +2138,7 @@ When run interactively HOST-OR-URL is read from the minibuffer." (interactive) (setq-local elpher-current-page nil) (setq-local elpher-history nil) - (elpher-visit-page (elpher-make-welcome-page))) + (elpher-visit-page (elpher-make-start-page))) (defun elpher-download () "Download the link at point." @@ -2146,11 +2146,12 @@ When run interactively HOST-OR-URL is read from the minibuffer." (let ((button (button-at (point)))) (if button (let ((page (button-get button 'elpher-page))) - (if (elpher-address-special-p (elpher-page-address page)) - (error "Cannot download %s" - (elpher-page-display-string page)) - (elpher-visit-page (button-get button 'elpher-page) - #'elpher-render-download))) + (unless page + (error "Not an elpher page")) + (when (elpher-address-special-p (elpher-page-address page)) + (error "Cannot download %s" (elpher-page-display-string page))) + (elpher-visit-page (button-get button 'elpher-page) + #'elpher-render-download)) (error "No link selected")))) (defun elpher-download-current () @@ -2206,17 +2207,18 @@ When run interactively HOST-OR-URL is read from the minibuffer." "Display information on PAGE." (let ((display-string (elpher-page-display-string page)) (address (elpher-page-address page))) - (if (elpher-address-special-p address) - (message "Special page: %s" display-string) - (message "%s" (elpher-address-to-url address))))) + (message "%s" (elpher-address-to-url address)))) (defun elpher-info-link () "Display information on page corresponding to link at point." (interactive) (let ((button (button-at (point)))) - (if button - (elpher-info-page (button-get button 'elpher-page)) - (error "No item selected")))) + (unless button + (error "No item selected")) + (let ((page (button-get button 'elpher-page))) + (unless page + (error "Not an elpher page")) + (elpher-info-page page)))) (defun elpher-info-current () "Display information on current page." @@ -2225,20 +2227,21 @@ When run interactively HOST-OR-URL is read from the minibuffer." (defun elpher-copy-page-url (page) "Copy URL representation of address of PAGE to `kill-ring'." - (let ((address (elpher-page-address page))) - (if (elpher-address-special-p address) - (error (format "Cannot represent %s as URL" (elpher-page-display-string page))) - (let ((url (elpher-address-to-url address))) - (message "Copied \"%s\" to kill-ring/clipboard." url) - (kill-new url))))) + (let* ((address (elpher-page-address page)) + (url (elpher-address-to-url address))) + (message "Copied \"%s\" to kill-ring/clipboard." url) + (kill-new url))) (defun elpher-copy-link-url () "Copy URL of item at point to `kill-ring'." (interactive) (let ((button (button-at (point)))) - (if button - (elpher-copy-page-url (button-get button 'elpher-page)) - (error "No item selected")))) + (unless button + (error "No item selected")) + (let ((page (button-get button 'elpher-page))) + (unless page + (error "Not an elpher page")) + (elpher-copy-page-url page)))) (defun elpher-copy-current-url () "Copy URL of current page to `kill-ring'." @@ -2366,7 +2369,7 @@ to create a new session. Returns the buffer selected (or created)." (pop-to-buffer-same-window buf) (unless (buffer-modified-p) (elpher-mode) - (elpher-visit-page (elpher-make-welcome-page)) + (elpher-visit-page (elpher-make-start-page)) "Started Elpher."))); Otherwise (elpher) evaluates to start page string. ;;; elpher.el ends here