diff options
| author | Stefan Monnier | 2013-05-26 21:08:43 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-05-26 21:08:43 -0400 |
| commit | 416f18027e1aa7a2af88d66a24b217fc84b7e2c7 (patch) | |
| tree | 9d28c53541efee32ee39ee1fa305d3fbb7a09775 | |
| parent | 4fd996b38978fe8a3117d58d92091f487af0507b (diff) | |
| download | emacs-416f18027e1aa7a2af88d66a24b217fc84b7e2c7.tar.gz emacs-416f18027e1aa7a2af88d66a24b217fc84b7e2c7.zip | |
* lisp/doc-view.el: Minor naming convention tweaks.
(desktop-buffer-mode-handlers): Don't add to it repeatedly.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/doc-view.el | 265 |
2 files changed, 134 insertions, 134 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7d3bbde6bc6..76d538f8add 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2013-05-27 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2013-05-27 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * doc-view.el: Minor naming convention tweaks. | ||
| 4 | (desktop-buffer-mode-handlers): Don't add to it repeatedly. | ||
| 5 | |||
| 3 | * image-mode.el (image-mode-reapply-winprops): Call image-mode-winprops | 6 | * image-mode.el (image-mode-reapply-winprops): Call image-mode-winprops |
| 4 | even if there's no `display' property yet (bug#14435). | 7 | even if there's no `display' property yet (bug#14435). |
| 5 | 8 | ||
diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 3a4a8138237..e4434c3a0d8 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el | |||
| @@ -305,9 +305,8 @@ of the page moves to the previous page." | |||
| 305 | 305 | ||
| 306 | ;;;; Internal Variables | 306 | ;;;; Internal Variables |
| 307 | 307 | ||
| 308 | (defvar doc-view-current-converter-processes nil | 308 | (defvar-local doc-view--current-converter-processes nil |
| 309 | "Only used internally.") | 309 | "Only used internally.") |
| 310 | (make-variable-buffer-local 'doc-view-current-converter-processes) | ||
| 311 | 310 | ||
| 312 | (defun doc-view-new-window-function (winprops) | 311 | (defun doc-view-new-window-function (winprops) |
| 313 | ;; (message "New window %s for buf %s" (car winprops) (current-buffer)) | 312 | ;; (message "New window %s for buf %s" (car winprops) (current-buffer)) |
| @@ -330,7 +329,7 @@ of the page moves to the previous page." | |||
| 330 | (image-mode-window-put 'overlay ol winprops) | 329 | (image-mode-window-put 'overlay ol winprops) |
| 331 | (when (and (windowp (car winprops)) | 330 | (when (and (windowp (car winprops)) |
| 332 | (stringp (overlay-get ol 'display)) | 331 | (stringp (overlay-get ol 'display)) |
| 333 | (null doc-view-current-converter-processes)) | 332 | (null doc-view--current-converter-processes)) |
| 334 | ;; We're not displaying an image yet, so let's do so. This happens when | 333 | ;; We're not displaying an image yet, so let's do so. This happens when |
| 335 | ;; the buffer is displayed for the first time. | 334 | ;; the buffer is displayed for the first time. |
| 336 | ;; Don't do it if there's a conversion is running, since in that case, it | 335 | ;; Don't do it if there's a conversion is running, since in that case, it |
| @@ -338,29 +337,25 @@ of the page moves to the previous page." | |||
| 338 | (with-selected-window (car winprops) | 337 | (with-selected-window (car winprops) |
| 339 | (doc-view-goto-page 1))))) | 338 | (doc-view-goto-page 1))))) |
| 340 | 339 | ||
| 341 | (defvar doc-view-current-files nil | 340 | (defvar-local doc-view--current-files nil |
| 342 | "Only used internally.") | 341 | "Only used internally.") |
| 343 | (make-variable-buffer-local 'doc-view-current-files) | ||
| 344 | 342 | ||
| 345 | (defvar doc-view-current-timer nil | 343 | (defvar-local doc-view--current-timer nil |
| 346 | "Only used internally.") | 344 | "Only used internally.") |
| 347 | (make-variable-buffer-local 'doc-view-current-timer) | ||
| 348 | 345 | ||
| 349 | (defvar doc-view-current-cache-dir nil | 346 | (defvar-local doc-view--current-cache-dir nil |
| 350 | "Only used internally.") | 347 | "Only used internally.") |
| 351 | (make-variable-buffer-local 'doc-view-current-cache-dir) | ||
| 352 | 348 | ||
| 353 | (defvar doc-view-current-search-matches nil | 349 | (defvar-local doc-view--current-search-matches nil |
| 354 | "Only used internally.") | 350 | "Only used internally.") |
| 355 | (make-variable-buffer-local 'doc-view-current-search-matches) | ||
| 356 | 351 | ||
| 357 | (defvar doc-view-pending-cache-flush nil | 352 | (defvar doc-view--pending-cache-flush nil |
| 358 | "Only used internally.") | 353 | "Only used internally.") |
| 359 | 354 | ||
| 360 | (defvar doc-view-previous-major-mode nil | 355 | (defvar doc-view--previous-major-mode nil |
| 361 | "Only used internally.") | 356 | "Only used internally.") |
| 362 | 357 | ||
| 363 | (defvar doc-view-buffer-file-name nil | 358 | (defvar doc-view--buffer-file-name nil |
| 364 | "Only used internally. | 359 | "Only used internally. |
| 365 | The file name used for conversion. Normally it's the same as | 360 | The file name used for conversion. Normally it's the same as |
| 366 | `buffer-file-name', but for remote files, compressed files and | 361 | `buffer-file-name', but for remote files, compressed files and |
| @@ -488,7 +483,7 @@ Typically \"page-%s.png\".") | |||
| 488 | (defmacro doc-view-current-slice () `(image-mode-window-get 'slice)) | 483 | (defmacro doc-view-current-slice () `(image-mode-window-get 'slice)) |
| 489 | 484 | ||
| 490 | (defun doc-view-last-page-number () | 485 | (defun doc-view-last-page-number () |
| 491 | (length doc-view-current-files)) | 486 | (length doc-view--current-files)) |
| 492 | 487 | ||
| 493 | (defun doc-view-goto-page (page) | 488 | (defun doc-view-goto-page (page) |
| 494 | "View the page given by PAGE." | 489 | "View the page given by PAGE." |
| @@ -499,7 +494,7 @@ Typically \"page-%s.png\".") | |||
| 499 | (when (and (> page len) | 494 | (when (and (> page len) |
| 500 | ;; As long as the converter is running, we don't know | 495 | ;; As long as the converter is running, we don't know |
| 501 | ;; how many pages will be available. | 496 | ;; how many pages will be available. |
| 502 | (null doc-view-current-converter-processes)) | 497 | (null doc-view--current-converter-processes)) |
| 503 | (setq page len))) | 498 | (setq page len))) |
| 504 | (setf (doc-view-current-page) page | 499 | (setf (doc-view-current-page) page |
| 505 | (doc-view-current-info) | 500 | (doc-view-current-info) |
| @@ -507,31 +502,31 @@ Typically \"page-%s.png\".") | |||
| 507 | (propertize | 502 | (propertize |
| 508 | (format "Page %d of %d." page len) 'face 'bold) | 503 | (format "Page %d of %d." page len) 'face 'bold) |
| 509 | ;; Tell user if converting isn't finished yet | 504 | ;; Tell user if converting isn't finished yet |
| 510 | (if doc-view-current-converter-processes | 505 | (if doc-view--current-converter-processes |
| 511 | " (still converting...)\n" | 506 | " (still converting...)\n" |
| 512 | "\n") | 507 | "\n") |
| 513 | ;; Display context infos if this page matches the last search | 508 | ;; Display context infos if this page matches the last search |
| 514 | (when (and doc-view-current-search-matches | 509 | (when (and doc-view--current-search-matches |
| 515 | (assq page doc-view-current-search-matches)) | 510 | (assq page doc-view--current-search-matches)) |
| 516 | (concat (propertize "Search matches:\n" 'face 'bold) | 511 | (concat (propertize "Search matches:\n" 'face 'bold) |
| 517 | (let ((contexts "")) | 512 | (let ((contexts "")) |
| 518 | (dolist (m (cdr (assq page | 513 | (dolist (m (cdr (assq page |
| 519 | doc-view-current-search-matches))) | 514 | doc-view--current-search-matches))) |
| 520 | (setq contexts (concat contexts " - \"" m "\"\n"))) | 515 | (setq contexts (concat contexts " - \"" m "\"\n"))) |
| 521 | contexts))))) | 516 | contexts))))) |
| 522 | ;; Update the buffer | 517 | ;; Update the buffer |
| 523 | ;; We used to find the file name from doc-view-current-files but | 518 | ;; We used to find the file name from doc-view--current-files but |
| 524 | ;; that's not right if the pages are not generated sequentially | 519 | ;; that's not right if the pages are not generated sequentially |
| 525 | ;; or if the page isn't in doc-view-current-files yet. | 520 | ;; or if the page isn't in doc-view--current-files yet. |
| 526 | (let ((file (expand-file-name | 521 | (let ((file (expand-file-name |
| 527 | (format doc-view--image-file-pattern page) | 522 | (format doc-view--image-file-pattern page) |
| 528 | (doc-view-current-cache-dir)))) | 523 | (doc-view--current-cache-dir)))) |
| 529 | (doc-view-insert-image file :pointer 'arrow) | 524 | (doc-view-insert-image file :pointer 'arrow) |
| 530 | (when (and (not (file-exists-p file)) | 525 | (when (and (not (file-exists-p file)) |
| 531 | doc-view-current-converter-processes) | 526 | doc-view--current-converter-processes) |
| 532 | ;; The PNG file hasn't been generated yet. | 527 | ;; The PNG file hasn't been generated yet. |
| 533 | (funcall doc-view-single-page-converter-function | 528 | (funcall doc-view-single-page-converter-function |
| 534 | doc-view-buffer-file-name file page | 529 | doc-view--buffer-file-name file page |
| 535 | (let ((win (selected-window))) | 530 | (let ((win (selected-window))) |
| 536 | (lambda () | 531 | (lambda () |
| 537 | (and (eq (current-buffer) (window-buffer win)) | 532 | (and (eq (current-buffer) (window-buffer win)) |
| @@ -636,13 +631,13 @@ at the top edge of the page moves to the previous page." | |||
| 636 | (defun doc-view-kill-proc () | 631 | (defun doc-view-kill-proc () |
| 637 | "Kill the current converter process(es)." | 632 | "Kill the current converter process(es)." |
| 638 | (interactive) | 633 | (interactive) |
| 639 | (while (consp doc-view-current-converter-processes) | 634 | (while (consp doc-view--current-converter-processes) |
| 640 | (ignore-errors ;; Some entries might not be processes, and maybe | 635 | (ignore-errors ;; Some entries might not be processes, and maybe |
| 641 | ;; some are dead already? | 636 | ;; some are dead already? |
| 642 | (kill-process (pop doc-view-current-converter-processes)))) | 637 | (kill-process (pop doc-view--current-converter-processes)))) |
| 643 | (when doc-view-current-timer | 638 | (when doc-view--current-timer |
| 644 | (cancel-timer doc-view-current-timer) | 639 | (cancel-timer doc-view--current-timer) |
| 645 | (setq doc-view-current-timer nil)) | 640 | (setq doc-view--current-timer nil)) |
| 646 | (setq mode-line-process nil)) | 641 | (setq mode-line-process nil)) |
| 647 | 642 | ||
| 648 | (defun doc-view-kill-proc-and-buffer () | 643 | (defun doc-view-kill-proc-and-buffer () |
| @@ -682,21 +677,21 @@ at the top edge of the page moves to the previous page." | |||
| 682 | (format "Unable to use temporary directory %s: %s" | 677 | (format "Unable to use temporary directory %s: %s" |
| 683 | dir (mapconcat 'identity (cdr error) " ")))))))) | 678 | dir (mapconcat 'identity (cdr error) " ")))))))) |
| 684 | 679 | ||
| 685 | (defun doc-view-current-cache-dir () | 680 | (defun doc-view--current-cache-dir () |
| 686 | "Return the directory where the png files of the current doc should be saved. | 681 | "Return the directory where the png files of the current doc should be saved. |
| 687 | It's a subdirectory of `doc-view-cache-directory'." | 682 | It's a subdirectory of `doc-view-cache-directory'." |
| 688 | (if doc-view-current-cache-dir | 683 | (if doc-view--current-cache-dir |
| 689 | doc-view-current-cache-dir | 684 | doc-view--current-cache-dir |
| 690 | ;; Try and make sure doc-view-cache-directory exists and is safe. | 685 | ;; Try and make sure doc-view-cache-directory exists and is safe. |
| 691 | (doc-view-make-safe-dir doc-view-cache-directory) | 686 | (doc-view-make-safe-dir doc-view-cache-directory) |
| 692 | ;; Now compute the subdirectory to use. | 687 | ;; Now compute the subdirectory to use. |
| 693 | (setq doc-view-current-cache-dir | 688 | (setq doc-view--current-cache-dir |
| 694 | (file-name-as-directory | 689 | (file-name-as-directory |
| 695 | (expand-file-name | 690 | (expand-file-name |
| 696 | (concat (subst-char-in-string ?% ?_ ;; bug#13679 | 691 | (concat (subst-char-in-string ?% ?_ ;; bug#13679 |
| 697 | (file-name-nondirectory doc-view-buffer-file-name)) | 692 | (file-name-nondirectory doc-view--buffer-file-name)) |
| 698 | "-" | 693 | "-" |
| 699 | (let ((file doc-view-buffer-file-name)) | 694 | (let ((file doc-view--buffer-file-name)) |
| 700 | (with-temp-buffer | 695 | (with-temp-buffer |
| 701 | (set-buffer-multibyte nil) | 696 | (set-buffer-multibyte nil) |
| 702 | (insert-file-contents-literally file) | 697 | (insert-file-contents-literally file) |
| @@ -846,8 +841,8 @@ Should be invoked when the cached images aren't up-to-date." | |||
| 846 | (interactive) | 841 | (interactive) |
| 847 | (doc-view-kill-proc) | 842 | (doc-view-kill-proc) |
| 848 | ;; Clear the old cached files | 843 | ;; Clear the old cached files |
| 849 | (when (file-exists-p (doc-view-current-cache-dir)) | 844 | (when (file-exists-p (doc-view--current-cache-dir)) |
| 850 | (delete-directory (doc-view-current-cache-dir) 'recursive)) | 845 | (delete-directory (doc-view--current-cache-dir) 'recursive)) |
| 851 | (kill-local-variable 'doc-view-last-page-number) | 846 | (kill-local-variable 'doc-view-last-page-number) |
| 852 | (doc-view-initiate-display)) | 847 | (doc-view-initiate-display)) |
| 853 | 848 | ||
| @@ -861,11 +856,11 @@ Should be invoked when the cached images aren't up-to-date." | |||
| 861 | event)) | 856 | event)) |
| 862 | (when (buffer-live-p (process-get proc 'buffer)) | 857 | (when (buffer-live-p (process-get proc 'buffer)) |
| 863 | (with-current-buffer (process-get proc 'buffer) | 858 | (with-current-buffer (process-get proc 'buffer) |
| 864 | (setq doc-view-current-converter-processes | 859 | (setq doc-view--current-converter-processes |
| 865 | (delq proc doc-view-current-converter-processes)) | 860 | (delq proc doc-view--current-converter-processes)) |
| 866 | (setq mode-line-process | 861 | (setq mode-line-process |
| 867 | (if doc-view-current-converter-processes | 862 | (if doc-view--current-converter-processes |
| 868 | (format ":%s" (car doc-view-current-converter-processes)))) | 863 | (format ":%s" (car doc-view--current-converter-processes)))) |
| 869 | (funcall (process-get proc 'callback)))))) | 864 | (funcall (process-get proc 'callback)))))) |
| 870 | 865 | ||
| 871 | (defun doc-view-start-process (name program args callback) | 866 | (defun doc-view-start-process (name program args callback) |
| @@ -876,7 +871,7 @@ Should be invoked when the cached images aren't up-to-date." | |||
| 876 | (expand-file-name "~/"))) | 871 | (expand-file-name "~/"))) |
| 877 | (proc (apply 'start-process name doc-view-conversion-buffer | 872 | (proc (apply 'start-process name doc-view-conversion-buffer |
| 878 | program args))) | 873 | program args))) |
| 879 | (push proc doc-view-current-converter-processes) | 874 | (push proc doc-view--current-converter-processes) |
| 880 | (setq mode-line-process (list (format ":%s" proc))) | 875 | (setq mode-line-process (list (format ":%s" proc))) |
| 881 | (set-process-sentinel proc 'doc-view-sentinel) | 876 | (set-process-sentinel proc 'doc-view-sentinel) |
| 882 | (process-put proc 'buffer (current-buffer)) | 877 | (process-put proc 'buffer (current-buffer)) |
| @@ -939,7 +934,7 @@ If PAGE is nil, convert the whole document." | |||
| 939 | The converted PDF is put into the current cache directory, and it | 934 | The converted PDF is put into the current cache directory, and it |
| 940 | is named like ODF with the extension turned to pdf." | 935 | is named like ODF with the extension turned to pdf." |
| 941 | (doc-view-start-process "odf->pdf" doc-view-odf->pdf-converter-program | 936 | (doc-view-start-process "odf->pdf" doc-view-odf->pdf-converter-program |
| 942 | (list "-f" "pdf" "-o" (doc-view-current-cache-dir) odf) | 937 | (list "-f" "pdf" "-o" (doc-view--current-cache-dir) odf) |
| 943 | callback)) | 938 | callback)) |
| 944 | 939 | ||
| 945 | (defun doc-view-odf->pdf-converter-soffice (odf callback) | 940 | (defun doc-view-odf->pdf-converter-soffice (odf callback) |
| @@ -957,7 +952,7 @@ is named like ODF with the extension turned to pdf." | |||
| 957 | (concat "-env:UserInstallation=file://" | 952 | (concat "-env:UserInstallation=file://" |
| 958 | tmp-user-install-dir) | 953 | tmp-user-install-dir) |
| 959 | "--headless" "--convert-to" "pdf" | 954 | "--headless" "--convert-to" "pdf" |
| 960 | "--outdir" (doc-view-current-cache-dir) odf) | 955 | "--outdir" (doc-view--current-cache-dir) odf) |
| 961 | (lambda () | 956 | (lambda () |
| 962 | (delete-directory tmp-user-install-dir t) | 957 | (delete-directory tmp-user-install-dir t) |
| 963 | (funcall callback))))) | 958 | (funcall callback))))) |
| @@ -977,16 +972,16 @@ is named like ODF with the extension turned to pdf." | |||
| 977 | ;; serves as a witness that the conversion is complete. | 972 | ;; serves as a witness that the conversion is complete. |
| 978 | (write-region (prin1-to-string resolution) nil | 973 | (write-region (prin1-to-string resolution) nil |
| 979 | (expand-file-name "resolution.el" | 974 | (expand-file-name "resolution.el" |
| 980 | (doc-view-current-cache-dir)) | 975 | (doc-view--current-cache-dir)) |
| 981 | nil 'silently) | 976 | nil 'silently) |
| 982 | (when doc-view-current-timer | 977 | (when doc-view--current-timer |
| 983 | (cancel-timer doc-view-current-timer) | 978 | (cancel-timer doc-view--current-timer) |
| 984 | (setq doc-view-current-timer nil)) | 979 | (setq doc-view--current-timer nil)) |
| 985 | (doc-view-display (current-buffer) 'force)))) | 980 | (doc-view-display (current-buffer) 'force)))) |
| 986 | 981 | ||
| 987 | ;; Update the displayed pages as soon as they're done generating. | 982 | ;; Update the displayed pages as soon as they're done generating. |
| 988 | (when doc-view-conversion-refresh-interval | 983 | (when doc-view-conversion-refresh-interval |
| 989 | (setq doc-view-current-timer | 984 | (setq doc-view--current-timer |
| 990 | (run-at-time "1 secs" doc-view-conversion-refresh-interval | 985 | (run-at-time "1 secs" doc-view-conversion-refresh-interval |
| 991 | 'doc-view-display | 986 | 'doc-view-display |
| 992 | (current-buffer))))) | 987 | (current-buffer))))) |
| @@ -1031,20 +1026,20 @@ Start by converting PAGES, and then the rest." | |||
| 1031 | (defun doc-view-current-cache-doc-pdf () | 1026 | (defun doc-view-current-cache-doc-pdf () |
| 1032 | "Return the name of the doc.pdf in the current cache dir. | 1027 | "Return the name of the doc.pdf in the current cache dir. |
| 1033 | This file exists only if the current document isn't a PDF or PS file already." | 1028 | This file exists only if the current document isn't a PDF or PS file already." |
| 1034 | (expand-file-name "doc.pdf" (doc-view-current-cache-dir))) | 1029 | (expand-file-name "doc.pdf" (doc-view--current-cache-dir))) |
| 1035 | 1030 | ||
| 1036 | (defun doc-view-doc->txt (txt callback) | 1031 | (defun doc-view-doc->txt (txt callback) |
| 1037 | "Convert the current document to text and call CALLBACK when done." | 1032 | "Convert the current document to text and call CALLBACK when done." |
| 1038 | (make-directory (doc-view-current-cache-dir) t) | 1033 | (make-directory (doc-view--current-cache-dir) t) |
| 1039 | (pcase doc-view-doc-type | 1034 | (pcase doc-view-doc-type |
| 1040 | 1035 | ||
| 1041 | ;; Doc is a PDF, so convert it to TXT | 1036 | ;; Doc is a PDF, so convert it to TXT |
| 1042 | (doc-view-pdf->txt doc-view-buffer-file-name txt callback)) | 1037 | (doc-view-pdf->txt doc-view--buffer-file-name txt callback)) |
| 1043 | (`ps | 1038 | (`ps |
| 1044 | ;; Doc is a PS, so convert it to PDF (which will be converted to | 1039 | ;; Doc is a PS, so convert it to PDF (which will be converted to |
| 1045 | ;; TXT thereafter). | 1040 | ;; TXT thereafter). |
| 1046 | (let ((pdf (doc-view-current-cache-doc-pdf))) | 1041 | (let ((pdf (doc-view-current-cache-doc-pdf))) |
| 1047 | (doc-view-ps->pdf doc-view-buffer-file-name pdf | 1042 | (doc-view-ps->pdf doc-view--buffer-file-name pdf |
| 1048 | (lambda () (doc-view-pdf->txt pdf txt callback))))) | 1043 | (lambda () (doc-view-pdf->txt pdf txt callback))))) |
| 1049 | (`dvi | 1044 | (`dvi |
| 1050 | ;; Doc is a DVI. This means that a doc.pdf already exists in its | 1045 | ;; Doc is a DVI. This means that a doc.pdf already exists in its |
| @@ -1077,39 +1072,39 @@ Start by converting PAGES, and then the rest." | |||
| 1077 | pages)) | 1072 | pages)) |
| 1078 | 1073 | ||
| 1079 | (defun doc-view-convert-current-doc () | 1074 | (defun doc-view-convert-current-doc () |
| 1080 | "Convert `doc-view-buffer-file-name' to a set of png files, one file per page. | 1075 | "Convert `doc-view--buffer-file-name' to a set of png files, one file per page. |
| 1081 | Those files are saved in the directory given by the function | 1076 | Those files are saved in the directory given by the function |
| 1082 | `doc-view-current-cache-dir'." | 1077 | `doc-view--current-cache-dir'." |
| 1083 | ;; Let stale files still display while we recompute the new ones, so only | 1078 | ;; Let stale files still display while we recompute the new ones, so only |
| 1084 | ;; flush the cache when the conversion is over. One of the reasons why it | 1079 | ;; flush the cache when the conversion is over. One of the reasons why it |
| 1085 | ;; is important to keep displaying the stale page is so that revert-buffer | 1080 | ;; is important to keep displaying the stale page is so that revert-buffer |
| 1086 | ;; preserves the horizontal/vertical scroll settings (which are otherwise | 1081 | ;; preserves the horizontal/vertical scroll settings (which are otherwise |
| 1087 | ;; resets during the redisplay). | 1082 | ;; reset during the redisplay). |
| 1088 | (setq doc-view-pending-cache-flush t) | 1083 | (setq doc-view--pending-cache-flush t) |
| 1089 | (let ((png-file (expand-file-name | 1084 | (let ((png-file (expand-file-name |
| 1090 | (format doc-view--image-file-pattern "%d") | 1085 | (format doc-view--image-file-pattern "%d") |
| 1091 | (doc-view-current-cache-dir)))) | 1086 | (doc-view--current-cache-dir)))) |
| 1092 | (make-directory (doc-view-current-cache-dir) t) | 1087 | (make-directory (doc-view--current-cache-dir) t) |
| 1093 | (pcase doc-view-doc-type | 1088 | (pcase doc-view-doc-type |
| 1094 | (`dvi | 1089 | (`dvi |
| 1095 | ;; DVI files have to be converted to PDF before Ghostscript can process | 1090 | ;; DVI files have to be converted to PDF before Ghostscript can process |
| 1096 | ;; it. | 1091 | ;; it. |
| 1097 | (let ((pdf (doc-view-current-cache-doc-pdf))) | 1092 | (let ((pdf (doc-view-current-cache-doc-pdf))) |
| 1098 | (doc-view-dvi->pdf doc-view-buffer-file-name pdf | 1093 | (doc-view-dvi->pdf doc-view--buffer-file-name pdf |
| 1099 | (lambda () (doc-view-pdf/ps->png pdf png-file))))) | 1094 | (lambda () (doc-view-pdf/ps->png pdf png-file))))) |
| 1100 | (`odf | 1095 | (`odf |
| 1101 | ;; ODF files have to be converted to PDF before Ghostscript can | 1096 | ;; ODF files have to be converted to PDF before Ghostscript can |
| 1102 | ;; process it. | 1097 | ;; process it. |
| 1103 | (let ((pdf (doc-view-current-cache-doc-pdf)) | 1098 | (let ((pdf (doc-view-current-cache-doc-pdf)) |
| 1104 | (opdf (expand-file-name | 1099 | (opdf (expand-file-name |
| 1105 | (concat (file-name-base doc-view-buffer-file-name) | 1100 | (concat (file-name-base doc-view--buffer-file-name) |
| 1106 | ".pdf") | 1101 | ".pdf") |
| 1107 | doc-view-current-cache-dir)) | 1102 | doc-view--current-cache-dir)) |
| 1108 | (png-file png-file)) | 1103 | (png-file png-file)) |
| 1109 | ;; The unoconv tool only supports an output directory, but no | 1104 | ;; The unoconv tool only supports an output directory, but no |
| 1110 | ;; file name. It's named like the input file with the | 1105 | ;; file name. It's named like the input file with the |
| 1111 | ;; extension replaced by pdf. | 1106 | ;; extension replaced by pdf. |
| 1112 | (funcall doc-view-odf->pdf-converter-function doc-view-buffer-file-name | 1107 | (funcall doc-view-odf->pdf-converter-function doc-view--buffer-file-name |
| 1113 | (lambda () | 1108 | (lambda () |
| 1114 | ;; Rename to doc.pdf | 1109 | ;; Rename to doc.pdf |
| 1115 | (rename-file opdf pdf) | 1110 | (rename-file opdf pdf) |
| @@ -1117,10 +1112,10 @@ Those files are saved in the directory given by the function | |||
| 1117 | ((or `pdf `djvu) | 1112 | ((or `pdf `djvu) |
| 1118 | (let ((pages (doc-view-active-pages))) | 1113 | (let ((pages (doc-view-active-pages))) |
| 1119 | ;; Convert doc to bitmap images starting with the active pages. | 1114 | ;; Convert doc to bitmap images starting with the active pages. |
| 1120 | (doc-view-document->bitmap doc-view-buffer-file-name png-file pages))) | 1115 | (doc-view-document->bitmap doc-view--buffer-file-name png-file pages))) |
| 1121 | (_ | 1116 | (_ |
| 1122 | ;; Convert to PNG images. | 1117 | ;; Convert to PNG images. |
| 1123 | (doc-view-pdf/ps->png doc-view-buffer-file-name png-file))))) | 1118 | (doc-view-pdf/ps->png doc-view--buffer-file-name png-file))))) |
| 1124 | 1119 | ||
| 1125 | ;;;; Slicing | 1120 | ;;;; Slicing |
| 1126 | 1121 | ||
| @@ -1171,7 +1166,7 @@ dragging it to its bottom-right corner. See also | |||
| 1171 | (doc (let ((cache-doc (doc-view-current-cache-doc-pdf))) | 1166 | (doc (let ((cache-doc (doc-view-current-cache-doc-pdf))) |
| 1172 | (if (file-exists-p cache-doc) | 1167 | (if (file-exists-p cache-doc) |
| 1173 | cache-doc | 1168 | cache-doc |
| 1174 | doc-view-buffer-file-name))) | 1169 | doc-view--buffer-file-name))) |
| 1175 | (o (shell-command-to-string | 1170 | (o (shell-command-to-string |
| 1176 | (concat doc-view-ghostscript-program | 1171 | (concat doc-view-ghostscript-program |
| 1177 | " -dSAFER -dBATCH -dNOPAUSE -q -sDEVICE=bbox " | 1172 | " -dSAFER -dBATCH -dNOPAUSE -q -sDEVICE=bbox " |
| @@ -1255,9 +1250,9 @@ After calling this function whole pages will be visible again." | |||
| 1255 | (defun doc-view-insert-image (file &rest args) | 1250 | (defun doc-view-insert-image (file &rest args) |
| 1256 | "Insert the given png FILE. | 1251 | "Insert the given png FILE. |
| 1257 | ARGS is a list of image descriptors." | 1252 | ARGS is a list of image descriptors." |
| 1258 | (when doc-view-pending-cache-flush | 1253 | (when doc-view--pending-cache-flush |
| 1259 | (clear-image-cache) | 1254 | (clear-image-cache) |
| 1260 | (setq doc-view-pending-cache-flush nil)) | 1255 | (setq doc-view--pending-cache-flush nil)) |
| 1261 | (let ((ol (doc-view-current-overlay))) | 1256 | (let ((ol (doc-view-current-overlay))) |
| 1262 | ;; Only insert the image if the buffer is visible. | 1257 | ;; Only insert the image if the buffer is visible. |
| 1263 | (when (window-live-p (overlay-get ol 'window)) | 1258 | (when (window-live-p (overlay-get ol 'window)) |
| @@ -1291,7 +1286,7 @@ ARGS is a list of image descriptors." | |||
| 1291 | (list (cons 'slice slice) image) | 1286 | (list (cons 'slice slice) image) |
| 1292 | image)) | 1287 | image)) |
| 1293 | ;; We're trying to display a page that doesn't exist. | 1288 | ;; We're trying to display a page that doesn't exist. |
| 1294 | (doc-view-current-converter-processes | 1289 | (doc-view--current-converter-processes |
| 1295 | ;; Maybe the page doesn't exist *yet*. | 1290 | ;; Maybe the page doesn't exist *yet*. |
| 1296 | "Cannot display this page (yet)!") | 1291 | "Cannot display this page (yet)!") |
| 1297 | (t | 1292 | (t |
| @@ -1314,7 +1309,7 @@ ARGS is a list of image descriptors." | |||
| 1314 | 1309 | ||
| 1315 | (defun doc-view-sort (a b) | 1310 | (defun doc-view-sort (a b) |
| 1316 | "Return non-nil if A should be sorted before B. | 1311 | "Return non-nil if A should be sorted before B. |
| 1317 | Predicate for sorting `doc-view-current-files'." | 1312 | Predicate for sorting `doc-view--current-files'." |
| 1318 | (or (< (length a) (length b)) | 1313 | (or (< (length a) (length b)) |
| 1319 | (and (= (length a) (length b)) | 1314 | (and (= (length a) (length b)) |
| 1320 | (string< a b)))) | 1315 | (string< a b)))) |
| @@ -1324,24 +1319,24 @@ Predicate for sorting `doc-view-current-files'." | |||
| 1324 | If FORCE is non-nil, start viewing even if the document does not | 1319 | If FORCE is non-nil, start viewing even if the document does not |
| 1325 | have the page we want to view." | 1320 | have the page we want to view." |
| 1326 | (with-current-buffer buffer | 1321 | (with-current-buffer buffer |
| 1327 | (let ((prev-pages doc-view-current-files)) | 1322 | (let ((prev-pages doc-view--current-files)) |
| 1328 | (setq doc-view-current-files | 1323 | (setq doc-view--current-files |
| 1329 | (sort (directory-files (doc-view-current-cache-dir) t | 1324 | (sort (directory-files (doc-view--current-cache-dir) t |
| 1330 | (format doc-view--image-file-pattern | 1325 | (format doc-view--image-file-pattern |
| 1331 | "[0-9]+") | 1326 | "[0-9]+") |
| 1332 | t) | 1327 | t) |
| 1333 | 'doc-view-sort)) | 1328 | 'doc-view-sort)) |
| 1334 | (unless (eq (length prev-pages) (length doc-view-current-files)) | 1329 | (unless (eq (length prev-pages) (length doc-view--current-files)) |
| 1335 | (force-mode-line-update)) | 1330 | (force-mode-line-update)) |
| 1336 | (dolist (win (or (get-buffer-window-list buffer nil t) | 1331 | (dolist (win (or (get-buffer-window-list buffer nil t) |
| 1337 | (list t))) | 1332 | (list t))) |
| 1338 | (let* ((page (doc-view-current-page win)) | 1333 | (let* ((page (doc-view-current-page win)) |
| 1339 | (pagefile (expand-file-name | 1334 | (pagefile (expand-file-name |
| 1340 | (format doc-view--image-file-pattern page) | 1335 | (format doc-view--image-file-pattern page) |
| 1341 | (doc-view-current-cache-dir)))) | 1336 | (doc-view--current-cache-dir)))) |
| 1342 | (when (or force | 1337 | (when (or force |
| 1343 | (and (not (member pagefile prev-pages)) | 1338 | (and (not (member pagefile prev-pages)) |
| 1344 | (member pagefile doc-view-current-files))) | 1339 | (member pagefile doc-view--current-files))) |
| 1345 | (if (windowp win) | 1340 | (if (windowp win) |
| 1346 | (with-selected-window win | 1341 | (with-selected-window win |
| 1347 | (cl-assert (eq (current-buffer) buffer) t) | 1342 | (cl-assert (eq (current-buffer) buffer) t) |
| @@ -1376,9 +1371,9 @@ For now these keys are useful: | |||
| 1376 | (defun doc-view-open-text () | 1371 | (defun doc-view-open-text () |
| 1377 | "Open a buffer with the current doc's contents as text." | 1372 | "Open a buffer with the current doc's contents as text." |
| 1378 | (interactive) | 1373 | (interactive) |
| 1379 | (if doc-view-current-converter-processes | 1374 | (if doc-view--current-converter-processes |
| 1380 | (message "DocView: please wait till conversion finished.") | 1375 | (message "DocView: please wait till conversion finished.") |
| 1381 | (let ((txt (expand-file-name "doc.txt" (doc-view-current-cache-dir)))) | 1376 | (let ((txt (expand-file-name "doc.txt" (doc-view--current-cache-dir)))) |
| 1382 | (if (file-readable-p txt) | 1377 | (if (file-readable-p txt) |
| 1383 | (let ((name (concat "Text contents of " | 1378 | (let ((name (concat "Text contents of " |
| 1384 | (file-name-nondirectory buffer-file-name))) | 1379 | (file-name-nondirectory buffer-file-name))) |
| @@ -1468,25 +1463,25 @@ till now do that first. | |||
| 1468 | If BACKWARD is non-nil, jump to the previous match." | 1463 | If BACKWARD is non-nil, jump to the previous match." |
| 1469 | (interactive "P") | 1464 | (interactive "P") |
| 1470 | (if (and (not new-query) | 1465 | (if (and (not new-query) |
| 1471 | doc-view-current-search-matches) | 1466 | doc-view--current-search-matches) |
| 1472 | (if backward | 1467 | (if backward |
| 1473 | (doc-view-search-previous-match 1) | 1468 | (doc-view-search-previous-match 1) |
| 1474 | (doc-view-search-next-match 1)) | 1469 | (doc-view-search-next-match 1)) |
| 1475 | ;; New search, so forget the old results. | 1470 | ;; New search, so forget the old results. |
| 1476 | (setq doc-view-current-search-matches nil) | 1471 | (setq doc-view--current-search-matches nil) |
| 1477 | (let ((txt (expand-file-name "doc.txt" | 1472 | (let ((txt (expand-file-name "doc.txt" |
| 1478 | (doc-view-current-cache-dir)))) | 1473 | (doc-view--current-cache-dir)))) |
| 1479 | (if (file-readable-p txt) | 1474 | (if (file-readable-p txt) |
| 1480 | (progn | 1475 | (progn |
| 1481 | (setq doc-view-current-search-matches | 1476 | (setq doc-view--current-search-matches |
| 1482 | (doc-view-search-internal | 1477 | (doc-view-search-internal |
| 1483 | (read-from-minibuffer "Regexp: ") | 1478 | (read-from-minibuffer "Regexp: ") |
| 1484 | txt)) | 1479 | txt)) |
| 1485 | (message "DocView: search yielded %d matches." | 1480 | (message "DocView: search yielded %d matches." |
| 1486 | (doc-view-search-no-of-matches | 1481 | (doc-view-search-no-of-matches |
| 1487 | doc-view-current-search-matches))) | 1482 | doc-view--current-search-matches))) |
| 1488 | ;; We must convert to TXT first! | 1483 | ;; We must convert to TXT first! |
| 1489 | (if doc-view-current-converter-processes | 1484 | (if doc-view--current-converter-processes |
| 1490 | (message "DocView: please wait till conversion finished.") | 1485 | (message "DocView: please wait till conversion finished.") |
| 1491 | (doc-view-doc->txt txt (lambda () (doc-view-search nil)))))))) | 1486 | (doc-view-doc->txt txt (lambda () (doc-view-search nil)))))))) |
| 1492 | 1487 | ||
| @@ -1495,28 +1490,28 @@ If BACKWARD is non-nil, jump to the previous match." | |||
| 1495 | (interactive "p") | 1490 | (interactive "p") |
| 1496 | (let* ((next-pages (doc-view-remove-if | 1491 | (let* ((next-pages (doc-view-remove-if |
| 1497 | (lambda (i) (<= (car i) (doc-view-current-page))) | 1492 | (lambda (i) (<= (car i) (doc-view-current-page))) |
| 1498 | doc-view-current-search-matches)) | 1493 | doc-view--current-search-matches)) |
| 1499 | (page (car (nth (1- arg) next-pages)))) | 1494 | (page (car (nth (1- arg) next-pages)))) |
| 1500 | (if page | 1495 | (if page |
| 1501 | (doc-view-goto-page page) | 1496 | (doc-view-goto-page page) |
| 1502 | (when (and | 1497 | (when (and |
| 1503 | doc-view-current-search-matches | 1498 | doc-view--current-search-matches |
| 1504 | (y-or-n-p "No more matches after current page. Wrap to first match? ")) | 1499 | (y-or-n-p "No more matches after current page. Wrap to first match? ")) |
| 1505 | (doc-view-goto-page (caar doc-view-current-search-matches)))))) | 1500 | (doc-view-goto-page (caar doc-view--current-search-matches)))))) |
| 1506 | 1501 | ||
| 1507 | (defun doc-view-search-previous-match (arg) | 1502 | (defun doc-view-search-previous-match (arg) |
| 1508 | "Go to the ARGth previous matching page." | 1503 | "Go to the ARGth previous matching page." |
| 1509 | (interactive "p") | 1504 | (interactive "p") |
| 1510 | (let* ((prev-pages (doc-view-remove-if | 1505 | (let* ((prev-pages (doc-view-remove-if |
| 1511 | (lambda (i) (>= (car i) (doc-view-current-page))) | 1506 | (lambda (i) (>= (car i) (doc-view-current-page))) |
| 1512 | doc-view-current-search-matches)) | 1507 | doc-view--current-search-matches)) |
| 1513 | (page (car (nth (1- arg) (nreverse prev-pages))))) | 1508 | (page (car (nth (1- arg) (nreverse prev-pages))))) |
| 1514 | (if page | 1509 | (if page |
| 1515 | (doc-view-goto-page page) | 1510 | (doc-view-goto-page page) |
| 1516 | (when (and | 1511 | (when (and |
| 1517 | doc-view-current-search-matches | 1512 | doc-view--current-search-matches |
| 1518 | (y-or-n-p "No more matches before current page. Wrap to last match? ")) | 1513 | (y-or-n-p "No more matches before current page. Wrap to last match? ")) |
| 1519 | (doc-view-goto-page (caar (last doc-view-current-search-matches))))))) | 1514 | (doc-view-goto-page (caar (last doc-view--current-search-matches))))))) |
| 1520 | 1515 | ||
| 1521 | ;;;; User interface commands and the mode | 1516 | ;;;; User interface commands and the mode |
| 1522 | 1517 | ||
| @@ -1524,13 +1519,13 @@ If BACKWARD is non-nil, jump to the previous match." | |||
| 1524 | 1519 | ||
| 1525 | (defun doc-view-already-converted-p () | 1520 | (defun doc-view-already-converted-p () |
| 1526 | "Return non-nil if the current doc was already converted." | 1521 | "Return non-nil if the current doc was already converted." |
| 1527 | (and (file-exists-p (doc-view-current-cache-dir)) | 1522 | (and (file-exists-p (doc-view--current-cache-dir)) |
| 1528 | ;; Check that the resolution info is there, otherwise it means | 1523 | ;; Check that the resolution info is there, otherwise it means |
| 1529 | ;; the conversion is incomplete. | 1524 | ;; the conversion is incomplete. |
| 1530 | (file-readable-p (expand-file-name "resolution.el" | 1525 | (file-readable-p (expand-file-name "resolution.el" |
| 1531 | (doc-view-current-cache-dir))) | 1526 | (doc-view--current-cache-dir))) |
| 1532 | (> (length (directory-files | 1527 | (> (length (directory-files |
| 1533 | (doc-view-current-cache-dir) | 1528 | (doc-view--current-cache-dir) |
| 1534 | nil (format doc-view--image-file-pattern "[0-9]+"))) | 1529 | nil (format doc-view--image-file-pattern "[0-9]+"))) |
| 1535 | 0))) | 1530 | 0))) |
| 1536 | 1531 | ||
| @@ -1544,8 +1539,9 @@ If BACKWARD is non-nil, jump to the previous match." | |||
| 1544 | (progn | 1539 | (progn |
| 1545 | (message "DocView: using cached files!") | 1540 | (message "DocView: using cached files!") |
| 1546 | ;; Load the saved resolution. | 1541 | ;; Load the saved resolution. |
| 1547 | (let* ((res-file (expand-file-name "resolution.el" | 1542 | (let* ((res-file |
| 1548 | (doc-view-current-cache-dir))) | 1543 | (expand-file-name "resolution.el" |
| 1544 | (doc-view--current-cache-dir))) | ||
| 1549 | (res | 1545 | (res |
| 1550 | (with-temp-buffer | 1546 | (with-temp-buffer |
| 1551 | (when (file-readable-p res-file) | 1547 | (when (file-readable-p res-file) |
| @@ -1563,7 +1559,7 @@ If BACKWARD is non-nil, jump to the previous match." | |||
| 1563 | (message | 1559 | (message |
| 1564 | "%s" | 1560 | "%s" |
| 1565 | (concat "No PNG support is available, or some conversion utility for " | 1561 | (concat "No PNG support is available, or some conversion utility for " |
| 1566 | (file-name-extension doc-view-buffer-file-name) | 1562 | (file-name-extension doc-view--buffer-file-name) |
| 1567 | " files is missing.")) | 1563 | " files is missing.")) |
| 1568 | (when (and (executable-find doc-view-pdftotext-program) | 1564 | (when (and (executable-find doc-view-pdftotext-program) |
| 1569 | (y-or-n-p | 1565 | (y-or-n-p |
| @@ -1622,13 +1618,14 @@ If BACKWARD is non-nil, jump to the previous match." | |||
| 1622 | ((looking-at "%PDF") '(pdf)) | 1618 | ((looking-at "%PDF") '(pdf)) |
| 1623 | ((looking-at "\367\002") '(dvi)) | 1619 | ((looking-at "\367\002") '(dvi)) |
| 1624 | ((looking-at "AT&TFORM") '(djvu)))))) | 1620 | ((looking-at "AT&TFORM") '(djvu)))))) |
| 1625 | (setq-local doc-view-doc-type | 1621 | (setq-local |
| 1626 | (car (or (doc-view-intersection name-types content-types) | 1622 | doc-view-doc-type |
| 1627 | (when (and name-types content-types) | 1623 | (car (or (doc-view-intersection name-types content-types) |
| 1628 | (error "Conflicting types: name says %s but content says %s" | 1624 | (when (and name-types content-types) |
| 1629 | name-types content-types)) | 1625 | (error "Conflicting types: name says %s but content says %s" |
| 1630 | name-types content-types | 1626 | name-types content-types)) |
| 1631 | (error "Cannot determine the document type")))))) | 1627 | name-types content-types |
| 1628 | (error "Cannot determine the document type")))))) | ||
| 1632 | 1629 | ||
| 1633 | (defun doc-view-set-up-single-converter () | 1630 | (defun doc-view-set-up-single-converter () |
| 1634 | "Find the right single-page converter for the current document type" | 1631 | "Find the right single-page converter for the current document type" |
| @@ -1658,9 +1655,8 @@ If BACKWARD is non-nil, jump to the previous match." | |||
| 1658 | (doc-view-goto-page page) | 1655 | (doc-view-goto-page page) |
| 1659 | (when slice (apply 'doc-view-set-slice slice))))) | 1656 | (when slice (apply 'doc-view-set-slice slice))))) |
| 1660 | 1657 | ||
| 1661 | (setq desktop-buffer-mode-handlers | 1658 | (add-to-list 'desktop-buffer-mode-handlers |
| 1662 | (cons '(doc-view-mode . doc-view-restore-desktop-buffer) | 1659 | '(doc-view-mode . doc-view-restore-desktop-buffer)) |
| 1663 | desktop-buffer-mode-handlers)) | ||
| 1664 | 1660 | ||
| 1665 | ;;;###autoload | 1661 | ;;;###autoload |
| 1666 | (defun doc-view-mode () | 1662 | (defun doc-view-mode () |
| @@ -1681,11 +1677,11 @@ toggle between displaying the document or editing it as text. | |||
| 1681 | (doc-view-fallback-mode) | 1677 | (doc-view-fallback-mode) |
| 1682 | 1678 | ||
| 1683 | (let* ((prev-major-mode (if (derived-mode-p 'doc-view-mode) | 1679 | (let* ((prev-major-mode (if (derived-mode-p 'doc-view-mode) |
| 1684 | doc-view-previous-major-mode | 1680 | doc-view--previous-major-mode |
| 1685 | (unless (eq major-mode 'fundamental-mode) | 1681 | (unless (eq major-mode 'fundamental-mode) |
| 1686 | major-mode)))) | 1682 | major-mode)))) |
| 1687 | (kill-all-local-variables) | 1683 | (kill-all-local-variables) |
| 1688 | (setq-local doc-view-previous-major-mode prev-major-mode)) | 1684 | (setq-local doc-view--previous-major-mode prev-major-mode)) |
| 1689 | 1685 | ||
| 1690 | (dolist (var doc-view-saved-settings) | 1686 | (dolist (var doc-view-saved-settings) |
| 1691 | (set (make-local-variable (car var)) (cdr var))) | 1687 | (set (make-local-variable (car var)) (cdr var))) |
| @@ -1697,29 +1693,30 @@ toggle between displaying the document or editing it as text. | |||
| 1697 | 1693 | ||
| 1698 | (doc-view-make-safe-dir doc-view-cache-directory) | 1694 | (doc-view-make-safe-dir doc-view-cache-directory) |
| 1699 | ;; Handle compressed files, remote files, files inside archives | 1695 | ;; Handle compressed files, remote files, files inside archives |
| 1700 | (setq-local doc-view-buffer-file-name | 1696 | (setq-local doc-view--buffer-file-name |
| 1701 | (cond | 1697 | (cond |
| 1702 | (jka-compr-really-do-compress | 1698 | (jka-compr-really-do-compress |
| 1703 | ;; FIXME: there's a risk of name conflicts here. | 1699 | ;; FIXME: there's a risk of name conflicts here. |
| 1704 | (expand-file-name | 1700 | (expand-file-name |
| 1705 | (file-name-nondirectory | 1701 | (file-name-nondirectory |
| 1706 | (file-name-sans-extension buffer-file-name)) | 1702 | (file-name-sans-extension buffer-file-name)) |
| 1707 | doc-view-cache-directory)) | 1703 | doc-view-cache-directory)) |
| 1708 | ;; Is the file readable by local processes? | 1704 | ;; Is the file readable by local processes? |
| 1709 | ;; We used to use `file-remote-p' but it's unclear what it's | 1705 | ;; We used to use `file-remote-p' but it's unclear what it's |
| 1710 | ;; supposed to return nil for things like local files accessed via | 1706 | ;; supposed to return nil for things like local files accessed |
| 1711 | ;; `su' or via file://... | 1707 | ;; via `su' or via file://... |
| 1712 | ((let ((file-name-handler-alist nil)) | 1708 | ((let ((file-name-handler-alist nil)) |
| 1713 | (not (and buffer-file-name (file-readable-p buffer-file-name)))) | 1709 | (not (and buffer-file-name |
| 1714 | ;; FIXME: there's a risk of name conflicts here. | 1710 | (file-readable-p buffer-file-name)))) |
| 1715 | (expand-file-name | 1711 | ;; FIXME: there's a risk of name conflicts here. |
| 1716 | (if buffer-file-name | 1712 | (expand-file-name |
| 1717 | (file-name-nondirectory buffer-file-name) | 1713 | (if buffer-file-name |
| 1718 | (buffer-name)) | 1714 | (file-name-nondirectory buffer-file-name) |
| 1719 | doc-view-cache-directory)) | 1715 | (buffer-name)) |
| 1720 | (t buffer-file-name))) | 1716 | doc-view-cache-directory)) |
| 1721 | (when (not (string= doc-view-buffer-file-name buffer-file-name)) | 1717 | (t buffer-file-name))) |
| 1722 | (write-region nil nil doc-view-buffer-file-name)) | 1718 | (when (not (string= doc-view--buffer-file-name buffer-file-name)) |
| 1719 | (write-region nil nil doc-view--buffer-file-name)) | ||
| 1723 | 1720 | ||
| 1724 | (add-hook 'change-major-mode-hook | 1721 | (add-hook 'change-major-mode-hook |
| 1725 | (lambda () | 1722 | (lambda () |
| @@ -1770,8 +1767,8 @@ toggle between displaying the document or editing it as text. | |||
| 1770 | '(doc-view-resolution | 1767 | '(doc-view-resolution |
| 1771 | image-mode-winprops-alist))))) | 1768 | image-mode-winprops-alist))))) |
| 1772 | (remove-overlays (point-min) (point-max) 'doc-view t) | 1769 | (remove-overlays (point-min) (point-max) 'doc-view t) |
| 1773 | (if doc-view-previous-major-mode | 1770 | (if doc-view--previous-major-mode |
| 1774 | (funcall doc-view-previous-major-mode) | 1771 | (funcall doc-view--previous-major-mode) |
| 1775 | (let ((auto-mode-alist | 1772 | (let ((auto-mode-alist |
| 1776 | (rassq-delete-all | 1773 | (rassq-delete-all |
| 1777 | 'doc-view-mode-maybe | 1774 | 'doc-view-mode-maybe |