From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: doc-view-set-doc-type's generality Date: Wed, 4 Dec 2019 15:05:08 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000001b32710598e14f8b" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="251092"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 04 15:06:39 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.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1icVIb-00136G-TV for ged-emacs-devel@m.gmane.org; Wed, 04 Dec 2019 15:06:38 +0100 Original-Received: from localhost ([::1]:39446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icVIa-0006ip-MD for ged-emacs-devel@m.gmane.org; Wed, 04 Dec 2019 09:06:36 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40179) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icVHo-0006eo-Jy for emacs-devel@gnu.org; Wed, 04 Dec 2019 09:05:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icVHn-0002bN-1k for emacs-devel@gnu.org; Wed, 04 Dec 2019 09:05:48 -0500 Original-Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]:43584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icVHm-0002av-Sr for emacs-devel@gnu.org; Wed, 04 Dec 2019 09:05:46 -0500 Original-Received: by mail-qv1-xf2c.google.com with SMTP id p2so3065633qvo.10 for ; Wed, 04 Dec 2019 06:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oQy5i1n4+Iqr0FSyB443+V/xDJ5ESOBI+9S929YuQXo=; b=Ulqp6WK+ycuTwRfvU3VMqforRnz71E2L5KqVzxKmWCMEZxu4z0sJ3rCdINMys03Ggg 5Cu4I8jLL6yhci1Kkvq6t1CYBfFbuh+BWbsLMkgs9tdRROmoAtjaf3PbO87WwhWP75PC McFO3WXEqd3pcjst39V8MaZ0vh7jlCRUTGC68CpO/9NmiYLyHgzd32/l1fvpBw/jmQj/ KEqcGiV1eOgee8OImvR2Z05kqTMIcsKLaeIVDH+5eM9W3mtJ+8MwgAn0MM/bSWa/lvGW yruR6v1fuh5K42k13tJoCY8BAGtfqLmhw//fRPSe0jHcPDhH0Mn/teUXnS3XoDUh3ekE 6lXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oQy5i1n4+Iqr0FSyB443+V/xDJ5ESOBI+9S929YuQXo=; b=XQhhUol0R1QcMpFLu+SKwVLwUBPmuYikDiBxDzpgz/6Ma98TNyJRq7pMyVViX/kNFh lLctvNacJzU4XONMXXyoyT/nwMrKo8+XpIGGUuU1FA+dYgSZ73KMvwBAutxtXq3YnCSP 47PQD1bUjX3kbcINSmwF51w/2hfDWQp6hwdTxxnD03lGAXBiIHd9ZToSxFrhpQDOTvz6 NW+qM0aKs0CN09FgszEeT04xnf+cLb9opyt5ZUgA9XI/QY1vy+QmQYylBlN616bHmeGr pvL/cUsqFWTeQvHBci2Sa/qZGZpEOMwPFshPdPY3oGlSUhcQL6gGZxdl6dxSKCjZh7cW pDcA== X-Gm-Message-State: APjAAAVUO3HidRr72GQudxoyVjnaw3raGD/t3bs/hZBYaKfiKBf2rMDZ aBKMT1Q6OKOlicW/lwgeAUuirepjSj9FqNQOJntyh9aM X-Google-Smtp-Source: APXvYqxzk5rw1Nst22G4bB1K5lLak5nQRf/cKXqADQXRy5hxMzx59wu+oYdRULmPeOX2XeD++RRK1UIBpUk0Zg/pE5c= X-Received: by 2002:ad4:450a:: with SMTP id k10mr2600646qvu.136.1575468345797; Wed, 04 Dec 2019 06:05:45 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::f2c X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:243121 Archived-At: --0000000000001b32710598e14f8b Content-Type: text/plain; charset="UTF-8" Well, yes, that's what it does. But it doesn't need to build a list of name-types based on just one file name and it does not need to build a list of content-types based on the beginning of just one buffer... I mean, AFAICS this would do the same and would not require `doc-view-intersection', just eq'ing two symbols. diff --git i/lisp/doc-view.el w/lisp/doc-view.el index e5f0e89a36..58f8535328 100644 --- i/lisp/doc-view.el +++ w/lisp/doc-view.el @@ -1753,4 +1753,5 @@ doc-view-clone-buffer-hook (defun doc-view-intersection (l1 l2) + (declare (obsolete nil "28.1")) (let ((l ())) (dolist (x l1) (if (memq x l2) (push x l))) @@ -1759,5 +1760,5 @@ doc-view-intersection (defun doc-view-set-doc-type () "Figure out the current document type (`doc-view-doc-type')." - (let ((name-types + (let ((name-type (when buffer-file-name (cdr (assoc-string @@ -1765,36 +1766,36 @@ doc-view-set-doc-type '( ;; DVI - ("dvi" dvi) + ("dvi" . dvi) ;; PDF - ("pdf" pdf) ("epdf" pdf) + ("pdf" . pdf) ("epdf" . pdf) ;; PostScript - ("ps" ps) ("eps" ps) + ("ps" . ps) ("eps" . ps) ;; DjVu - ("djvu" djvu) + ("djvu" . djvu) ;; OpenDocument formats. - ("odt" odf) ("ods" odf) ("odp" odf) ("odg" odf) - ("odc" odf) ("odi" odf) ("odm" odf) ("ott" odf) - ("ots" odf) ("otp" odf) ("otg" odf) + ("odt" . odf) ("ods" . odf) ("odp" . odf) ("odg" . odf) + ("odc" . odf) ("odi" . odf) ("odm" . odf) ("ott" . odf) + ("ots" . odf) ("otp" . odf) ("otg" . odf) ;; Microsoft Office formats (also handled by the odf ;; conversion chain). - ("doc" odf) ("docx" odf) ("xls" odf) ("xlsx" odf) - ("ppt" odf) ("pps" odf) ("pptx" odf) ("rtf" odf)) + ("doc" . odf) ("docx" . odf) ("xls" . odf) ("xlsx" . odf) + ("ppt" . odf) ("pps" . odf) ("pptx" . odf) ("rtf" . odf)) t)))) - (content-types + (content-type (save-excursion (goto-char (point-min)) (cond - ((looking-at "%!") '(ps)) - ((looking-at "%PDF") '(pdf)) - ((looking-at "\367\002") '(dvi)) - ((looking-at "AT&TFORM") '(djvu)))))) + ((looking-at "%!") 'ps) + ((looking-at "%PDF") 'pdf) + ((looking-at "\367\002") 'dvi) + ((looking-at "AT&TFORM") 'djvu))))) (setq-local doc-view-doc-type - (car (or (doc-view-intersection name-types content-types) - (when (and name-types content-types) - (error "Conflicting types: name says %s but content says %s" - name-types content-types)) - name-types content-types - (error "Cannot determine the document type")))))) + (or (and (eq name-type content-type) name-type) + (when (and name-type content-type) + (error "Conflicting types: name says %s but content says %s" + name-type content-type)) + name-type content-type + (error "Cannot determine the document type"))))) (defun doc-view-set-up-single-converter () --0000000000001b32710598e14f8b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Well, yes, that's what it doe= s. But it doesn't need to build a list of name-types
based on just one file name and it does not need to build= a list of content-types
based on= the beginning of just one buffer...

I mean, AFAICS this would do th= e same and would not require `doc-view-intersection',
= just eq'ing two symbols.

di= ff --git i/lisp/doc-view.el w/lisp/doc-view.el
index e5f0e89a36..58f8535= 328 100644
--- i/lisp/doc-view.el
+++ w/lisp/doc-view.el
@@ -1753,= 4 +1753,5 @@ doc-view-clone-buffer-hook
=C2=A0
=C2=A0(defun doc-view-= intersection (l1 l2)
+ =C2=A0(declare (obsolete nil "28.1"))=C2=A0 =C2=A0(let ((l ()))
=C2=A0 =C2=A0 =C2=A0(dolist (x l1) (if (mem= q x l2) (push x l)))
@@ -1759,5 +1760,5 @@ doc-view-intersection
=C2= =A0(defun doc-view-set-doc-type ()
=C2=A0 =C2=A0"Figure out the cur= rent document type (`doc-view-doc-type')."
- =C2=A0(let ((name-= types
+ =C2=A0(let ((name-type
=C2=A0 (when buffer-file-name
=C2= =A0 =C2=A0 (cdr (assoc-string
@@ -1765,36 +1766,36 @@ doc-view-set-doc-= type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '= ;(
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= ;; DVI
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= ("dvi" dvi)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 ("dvi" . dvi)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; PDF
- =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("pdf" pdf) ("epdf= " pdf)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ("pdf" . pdf) ("epdf" . pdf)
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; PostScript
- = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("ps&qu= ot; ps) ("eps" ps)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 ("ps" . ps) ("eps" . ps)
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; DjVu<= br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("= djvu" djvu)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 ("djvu" . djvu)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; OpenDocument formats.
- =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("odt" odf) = ("ods" odf) ("odp" odf) ("odg" odf)
- =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("odc"= ; odf) ("odi" odf) ("odm" odf) ("ott" odf)- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("ot= s" odf) ("otp" odf) ("otg" odf)
+ =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("odt" . odf) (= "ods" . odf) ("odp" . odf) ("odg" . odf)
+= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("odc&= quot; . odf) ("odi" . odf) ("odm" . odf) ("ott&quo= t; . odf)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 ("ots" . odf) ("otp" . odf) ("otg" . odf)=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;= ; Microsoft Office formats (also handled by the odf
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; conversion chain).
= - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ("doc= " odf) ("docx" odf) ("xls" odf) ("xlsx" = odf)
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (&= quot;ppt" odf) ("pps" odf) ("pptx" odf) ("rtf= " odf))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ("doc" . odf) ("docx" . odf) ("xls" . = odf) ("xlsx" . odf)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 ("ppt" . odf) ("pps" . odf) (&= quot;pptx" . odf) ("rtf" . odf))
=C2=A0 t))))
- (con= tent-types
+ (content-type
=C2=A0 (save-excursion
=C2=A0 =C2=A0 = (goto-char (point-min))
=C2=A0 =C2=A0 (cond
- =C2=A0 =C2=A0((lookin= g-at "%!") '(ps))
- =C2=A0 =C2=A0((looking-at "%PDF&= quot;) '(pdf))
- =C2=A0 =C2=A0((looking-at "\367\002") &#= 39;(dvi))
- =C2=A0 =C2=A0((looking-at "AT&TFORM") '(d= jvu))))))
+ =C2=A0 =C2=A0((looking-at "%!") 'ps)
+ = =C2=A0 =C2=A0((looking-at "%PDF") 'pdf)
+ =C2=A0 =C2=A0((= looking-at "\367\002") 'dvi)
+ =C2=A0 =C2=A0((looking-at = "AT&TFORM") 'djvu)))))
=C2=A0 =C2=A0 =C2=A0(setq-local=
=C2=A0 =C2=A0 =C2=A0 doc-view-doc-type
- =C2=A0 =C2=A0 (car (or (doc= -view-intersection name-types content-types)
- =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(when (and name-types content-types)
- =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(error "Conflicting ty= pes: name says %s but content says %s"
- =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 name-types content-typ= es))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0name-types conten= t-types
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(error "C= annot determine the document type"))))))
+ =C2=A0 =C2=A0 (or (and (= eq name-type content-type) name-type)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 (whe= n (and name-type content-type)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (err= or "Conflicting types: name says %s but content says %s"
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0name-type conten= t-type))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 name-type content-type
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (error "Cannot determine the document type&qu= ot;)))))
=C2=A0
=C2=A0(defun doc-view-set-up-single-converter ()
<= /font>
--0000000000001b32710598e14f8b--