diff options
Diffstat (limited to 'lib/doc')
-rw-r--r-- | lib/doc/jao-doc-view.el | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/doc/jao-doc-view.el b/lib/doc/jao-doc-view.el index 5c6cbbc..713caf9 100644 --- a/lib/doc/jao-doc-view.el +++ b/lib/doc/jao-doc-view.el @@ -87,10 +87,6 @@ (defun jao-doc-view-is-pdf (file) (string-match-p ".*\\.pdf$" file)) -(defun jao-doc-view-title (&optional fname) - (let ((base (file-name-base (or fname (buffer-file-name))))) - (capitalize (replace-regexp-in-string "-" " " base)))) - (defun jao-doc-view-title->file (title) (concat (mapconcat 'downcase (split-string title nil t) "-") ".pdf")) @@ -133,6 +129,12 @@ (setq outline (cdr outline))) (replace-regexp-in-string "[[:blank:]]+" " " cur-title))) +(defun jao-doc-view-title (&optional fname) + (if (or fname (not (derived-mode-p 'doc-view-mode 'pdf-view-mode))) + (let ((base (file-name-base (or fname (buffer-file-name))))) + (capitalize (replace-regexp-in-string "-" " " base))) + (or (jao-doc-view-section-title) (jao-doc-view-title buffer-file-name)))) + ;;; imenu (defun jao-doc-view--enable-imenu () @@ -187,7 +189,8 @@ (if doc-view--current-converter-processes (message "DocView: please wait till conversion finished.") (let ((txt (expand-file-name "doc.txt" (doc-view--current-cache-dir))) - (page (doc-view-current-page))) + (page (doc-view-current-page)) + (urls)) (if (file-readable-p txt) (with-current-buffer (find-file-noselect txt) (goto-char (point-min)) @@ -195,8 +198,7 @@ (let ((end (save-excursion (if (re-search-forward page-delimiter nil t) (point) - (point-max)))) - (urls)) + (point-max))))) (while (re-search-forward "https?://" end t) (push (thing-at-point-url-at-point) urls)) urls)) @@ -206,7 +208,7 @@ "Visit URL displayed in this page." (interactive nil doc-view-mode) (let ((urls (jao-doc-view--page-urls))) - (if (null urls) + (if (zerop (length urls)) (message "No URLs in this page") (when-let (url (completing-read "URL: " urls nil nil (when (null (cdr urls)) (car urls)))) |