diff options
author | Vasilij Schneidermann <mail@vasilij.de> | 2020-05-01 16:58:42 +0200 |
---|---|---|
committer | Vasilij Schneidermann <mail@vasilij.de> | 2020-05-01 16:58:42 +0200 |
commit | 2eec3f2e713baec814999359bb4580fbf2efd5b9 (patch) | |
tree | ff27385c474e399b028b77f6c032b6d9174f2e45 /nov.el | |
parent | cd1b264b3f978a9285fa9297e40ad29d1434adf5 (diff) |
Rework relative files visiting logic
Diffstat (limited to 'nov.el')
-rw-r--r-- | nov.el | 32 |
1 files changed, 17 insertions, 15 deletions
@@ -648,21 +648,23 @@ the HTML is rendered with `nov-render-html-function'." (defun nov-visit-relative-file (filename target) "Visit the document as specified by FILENAME and TARGET." - (let* ((current-path (cdr (aref nov-documents nov-documents-index))) - (directory (file-name-directory current-path)) - (path (file-truename (nov-make-path directory filename))) - (index (nov-find-document - (lambda (doc) (equal path (file-truename (cdr doc))))))) - (when (not index) - (error "Couldn't locate document")) - (let ((shr-target-id target)) - (nov-goto-document index)) - (when target - (let ((pos (next-single-property-change (point-min) 'shr-target-id))) - (when (not pos) - (error "Couldn't locate target")) - (goto-char pos) - (recenter (1- (max 1 scroll-margin))))))) + (let ((index nov-documents-index) + (shr-target-id target)) + (when (not (zerop (length filename))) + (let* ((current-path (cdr (aref nov-documents nov-documents-index))) + (directory (file-name-directory current-path)) + (path (file-truename (nov-make-path directory filename))) + (index (nov-find-document + (lambda (doc) (equal path (file-truename (cdr doc))))))) + (when (not index) + (error "Couldn't locate document")) + (nov-goto-document index)))) + (when target + (let ((pos (next-single-property-change (point-min) 'shr-target-id))) + (when (not pos) + (error "Couldn't locate target")) + (goto-char pos) + (recenter (1- (max 1 scroll-margin)))))) ;; adapted from `shr-browse-url' (defun nov-browse-url (&optional mouse-event) |