;; Author: Tim Vaughan <plugd@thelambdalab.xyz>
;; Created: 11 April 2019
-;; Version: 2.7.8
+;; Version: 2.7.9
;; Keywords: comm gopher
;; Homepage: http://thelambdalab.xyz/elpher
;; Package-Requires: ((emacs "26"))
;;; Global constants
;;
-(defconst elpher-version "2.7.8"
+(defconst elpher-version "2.7.9"
"Current version of elpher.")
(defconst elpher-margin-width 6
the time when the text is rendered."
:type '(integer))
+(defcustom elpher-gemini-link-string "→ "
+ "Specify the string used to indicate links when rendering gemini maps.
+May be empty."
+ :type '(string))
+
+(defcustom elpher-gemini-bullet-string "•"
+ "Specify the string used for bullets when rendering gemini maps."
+ :type '(string))
+
(defcustom elpher-bookmarks-file (locate-user-emacs-file "elpher-bookmarks")
"Specify the name of the file where elpher bookmarks will be saved."
:type '(file))
(insert " "))
(insert (make-string elpher-margin-width ?\s))))
-(defun elpher-page-button-help (page)
- "Return a string containing the help text for a button corresponding to PAGE."
- (let ((address (elpher-page-address page)))
- (format "mouse-1, RET: open '%s'" (if (elpher-address-special-p address)
- address
- (elpher-address-to-url address)))))
+(defun elpher--page-button-help (_window buffer pos)
+ "Function called by Emacs to generate mouse-over text.
+The arguments specify the BUFFER and the POS within the buffer of the item
+for which help is required. The function returns the help to be
+displayed. The _WINDOW argument is currently unused."
+ (with-current-buffer buffer
+ (let ((button (button-at pos)))
+ (when button
+ (let* ((page (button-get button 'elpher-page))
+ (address (elpher-page-address page)))
+ (format "mouse-1, RET: open '%s'" (if (elpher-address-special-p address)
+ address
+ (url-recreate-url address))))))))
(defun elpher-insert-index-record (display-string &optional address)
"Function to insert an index record into the current buffer.
'elpher-page page
'action #'elpher-click-link
'follow-link t
- 'help-echo (elpher-page-button-help page)))
+ 'help-echo #'elpher--page-button-help))
(pcase type
('nil ;; Information
(elpher-insert-margin)
'elpher-page page
'action #'elpher-click-link
'follow-link t
- 'help-echo (elpher-page-button-help page)
+ 'help-echo #'elpher--page-button-help
'face 'button)))
(buffer-string)))
(error "Cannot establish gemini connection: GnuTLS not available")
(unless (< (elpher-address-port address) 65536)
(error "Cannot establish gemini connection: port number > 65536"))
+ (defvar gnutls-verify-error)
(condition-case nil
(let* ((kill-buffer-query-functions nil)
(gnutls-verify-error nil) ; We use the NSM for verification
(type (if address (elpher-address-type address) nil))
(type-map-entry (cdr (assoc type elpher-type-map))))
(when display-string
- (insert "→ ")
+ (insert elpher-gemini-link-string)
(if type-map-entry
(let* ((face (elt type-map-entry 3))
(filtered-display-string (ansi-color-filter-apply display-string))
'elpher-page page
'action #'elpher-click-link
'follow-link t
- 'help-echo (elpher-page-button-help page)))
+ 'help-echo #'elpher--page-button-help))
(insert (propertize display-string 'face 'elpher-unknown)))
(insert "\n"))))
"Insert a plain non-preformatted TEXT-LINE into a text/gemini document.
This function uses Emacs' auto-fill to wrap text sensibly to a maximum
width defined by elpher-gemini-max-fill-width."
- (insert (elpher-process-text-for-display text-line))
- (let* ((prefix-end-idx (string-match "^[ \t]*\\(\*+[ \t]\\)?" text-line))
- (fill-prefix (replace-regexp-in-string "\*" " " (match-string 0 text-line))))
+ (string-match "\\(^[ \t]*\\)\\(\*[ \t]\\)?" text-line)
+ (let* ((processed-text-line (if (match-string 2 text-line)
+ (concat
+ (replace-regexp-in-string "\*"
+ elpher-gemini-bullet-string
+ (match-string 0 text-line))
+ (substring text-line (match-end 0)))
+ text-line))
+ (fill-prefix (if (match-string 1 text-line)
+ (replace-regexp-in-string "\*" " " (match-string 0 text-line))
+ nil)))
+ (insert (elpher-process-text-for-display processed-text-line))
(newline)))
(defun elpher-render-gemini-map (data _parameters)
;; Finger page connection
(defun elpher-get-finger-page (renderer &optional force-ipv4)
- "Opens a finger connection to the current page address and renders it using RENDERER."
+ "Opens a finger connection to the current page address.
+The result is rendered using RENDERER. When the optional argument
+FORCE-IPV4 is non-nil, the IPv4 address returned by a DNS lookup will
+be used explicitly in making the connection."
(let* ((address (elpher-page-address elpher-current-page))
(content (elpher-get-cached-content address)))
(if (and content (funcall renderer nil))
(cons string selector-string-parts))))
(set-process-sentinel proc
(lambda (_proc event)
- (condition-case the-error
+ (condition-case _the-error
(cond
((string-prefix-p "deleted" event))
((string-prefix-p "open" event)