From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.devel Subject: Re: DJVU files and ImageMagick Date: Mon, 04 Feb 2019 18:34:37 +0100 Message-ID: <87lg2vjw42.fsf@gmx.net> References: <87zhrdn8lf.fsf@gmx.net> <87va201e07.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="196912"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Roland Winkler Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 04 18:35:00 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gqi96-000p85-ER for ged-emacs-devel@m.gmane.org; Mon, 04 Feb 2019 18:35:00 +0100 Original-Received: from localhost ([127.0.0.1]:46510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqi95-0001fv-E7 for ged-emacs-devel@m.gmane.org; Mon, 04 Feb 2019 12:34:59 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqi8v-0001ea-RL for emacs-devel@gnu.org; Mon, 04 Feb 2019 12:34:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqi8u-0001dL-QI for emacs-devel@gnu.org; Mon, 04 Feb 2019 12:34:49 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:59141) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gqi8u-0001SW-FS; Mon, 04 Feb 2019 12:34:48 -0500 Original-Received: from rosalinde ([188.101.19.0]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LpsIh-1hNXvF30NT-00flEK; Mon, 04 Feb 2019 18:34:38 +0100 In-Reply-To: <87va201e07.fsf@gnu.org> (Roland Winkler's message of "Sun, 03 Feb 2019 20:30:48 -0600") X-Provags-ID: V03:K1:fIGCJCyuxPFYp044O6ChES10iqIO95j4ElQrFykbddKy0ZR1Sn1 jD9/SpJ9qPI0r++MR+u/7Pb0EvsJf/Pe82QcnAKo7LyoWMpy//JK+WSl2p7ubMhasV1woZW F+QkWBJmFORhaa9JOllpFxobvdBdczyimHoWEW5gttI8LNd7UnO/N9r6XIQTmkPQ7ufGr5O 17yHtpLcb2CHiHIM7bxcw== X-UI-Out-Filterresults: notjunk:1;V03:K0:BrMBzUYu5Es=:kovSe4cmWcApPv/EVi4ARu pJJe0+4J4Ox7E27cG/6O/mXfzBmQoQf0DQcylv05Maf4as0fTkkCTT43UKpiKG2Y/F8wsIl39 NAhZEaulTPE+enAJKKsQ69VnBK+4BqMHhI4x3CrQB4oCiCm954qV2Pc1qDAGXJU10FRVcMD73 GBooTVqD8JavRO4r9qJ1Wl6Uhla086CoQz/jbSZek1H39mcyPa/qdcUg7mBa8k9Noa2sbY3fB NutI0E7j+bgQt1+PBpX8tgf6Z3q0ytn+mE2ZkBvZauhiaXqsG+brBmuTr7KmNWlBw4Sp8ntMB F8tPpmEkrcQ9Sg4gZr0FNLuHgqx1Ey88xl5DngUi9ZQXysTgUL8D84qh9qT7EMIzQKlue4brP niVtj6Ra4nba7kltlygjeduoqePKfJDT540KWQnWgNRxmUsFtnwGMLWAlXzN2GoHR7OG8zS7C 9IjHAxj24zLF0RfTg3ss0pvvNrqE9+eXvxnOnevnaqrfTWr8u8weU5aJxnLrnIlVVfj+Wlap6 RAJDkULog/l8IC2ZaTsPLNIGPFo64Q3kIryc5xatr8GPMMcM0thpyHl/f8CdUWi82CmNpT4sX qBfrnC8oTPakEqoq3zdo3bHODHNKp3BVm3TlzLGjv+xNIXUHKPrtxUftcZ88o2vkODC6lCKn4 ynY1EtS6i3mHDlGdnlyNyKU69Hdf1cDBNhYyfwUZlyq7d2FHhZb3SReT3bHH3twi/zj8FLtFz 3/YN8Bhabp6kKMuznphjRVvppYT8DxQD2qtm1e44Zsg2NasXXJaz3NUvjN5jjVUiyVUZlB8p X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.15 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:232970 Archived-At: On Sun, 03 Feb 2019 20:30:48 -0600 Roland Winkler wrote: > On Sat, Feb 02 2019, Stephen Berman wrote: [...] >> (I normally view DJVU files in Emacs using the djvu package from ELPA > > Really? Hooray, someone else is using this package, too. I thought I > was the very only one. I'm quite happy with this package, and the current version is even more attractive compared to the previous one, especially the buttonized outline. There are a couple of features I miss; one is that I often like to open DJVU files from Dired, so I added this to my init file: (defun srb-djvu-mode () (let ((file (buffer-file-name))) (kill-buffer (file-name-nondirectory file)) (djvu-find-file file))) (add-to-list 'auto-mode-alist '("\\.djvu\\'" . srb-djvu-mode)) Another nice thing would be integration with the Emacs bookmark facility (I haven't tried using the djvu bookmark facility, but it looks like it's tied to djvu outlines, so orthogonal to Emacs bookmarks). I've tried adapting the bookmark integration in Andreas Politz's pdf-tools package, and it seems to works well enough for my purposes. I also like the way pdf-view-mode (and doc-view-mode) displays both the current and total number of pages, so I adapted djvu-read-mode to that as well. Here's the code, in case you or anyone else is interested: (defun djvu-bookmark-make-record () (cons (buffer-name) (append (bookmark-make-record-default nil t 1) `(,(cons 'page (djvu-ref page)) ,(cons 'size (djvu-ref pagesize)) (handler . djvu-view-bookmark-jump-handler))))) (defun djvu-view-bookmark-jump-handler (bmk) (let ((page (bookmark-prop-get bmk 'page)) ;; (slice (bookmark-prop-get bmk 'slice)) (size (bookmark-prop-get bmk 'size)) ;; (origin (bookmark-prop-get bmk 'origin)) (file (bookmark-prop-get bmk 'filename)) (show-fn-sym (make-symbol "djvu-bookmark-after-jump-hook"))) (fset show-fn-sym (lambda () (remove-hook 'bookmark-after-jump-hook show-fn-sym) (unless (derived-mode-p 'djvu-read-mode) (djvu-read-mode)) (with-selected-window (or (get-buffer-window (current-buffer) 0) (selected-window)) (when size (setq-local djvu-doc-pagesize size)) ;; (when slice ;; (apply 'pdf-view-set-slice slice)) (when (numberp page) (djvu-goto-page page)) ;; (when origin ;; (let ((size (pdf-view-image-size t))) ;; (image-set-window-hscroll ;; (round (/ (* (car origin) (car size)) ;; (frame-char-width)))) ;; (image-set-window-vscroll ;; (round (/ (* (cdr origin) (cdr size)) ;; (frame-char-height)))))) ))) (add-hook 'bookmark-after-jump-hook show-fn-sym) (set-buffer (or (find-buffer-visiting file) (find-file-noselect file))))) (define-derived-mode djvu-read-mode special-mode "Djview" "Mode for reading Djvu files." (setq djvu-buffer 'read buffer-undo-list t ;; mode-line-buffer-identification ;; (list 24 '(:eval (format "%s p%d" (buffer-name) (djvu-ref page)))) ) (setq-local mode-line-position '(" P" (:eval (number-to-string (djvu-ref page))) ;; Avoid errors during redisplay. "/" (:eval (or (ignore-errors (number-to-string (djvu-ref pagemax))) "???")))) (setq-local revert-buffer-function 'djvu-revert-buffer) (setq-local bookmark-make-record-function 'djvu-bookmark-make-record)) Thanks for the djvu package! Steve Berman