From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SLOxNJ63iWJWjAAAbAwnHQ (envelope-from ) for ; Sun, 22 May 2022 06:10:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id UNCrM563iWLoFAAAG6o9tA (envelope-from ) for ; Sun, 22 May 2022 06:10:06 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6A3CF6212 for ; Sun, 22 May 2022 06:10:06 +0200 (CEST) Received: from localhost ([::1]:37750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nscur-0005v9-2g for larch@yhetil.org; Sun, 22 May 2022 00:10:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nscuE-0005v0-IW for emacs-orgmode@gnu.org; Sun, 22 May 2022 00:09:26 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:37732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nscuC-0001OV-IQ for emacs-orgmode@gnu.org; Sun, 22 May 2022 00:09:26 -0400 Received: by mail-pg1-x52c.google.com with SMTP id h9so2759918pgl.4 for ; Sat, 21 May 2022 21:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=ROOEbYjWJqHyCtkw2fZQEfd0qrZ/Q2rB06eeS8VmaU8=; b=QHBDDobaP9a/69p/GOhZHDVtMOF5P8Cz8FeGZeSmg8jkkJ1L/w2yY8S8bwvPEgR5cg E6EnNpK4mrCwlPPWZ8+KqHKLoHepm1UvkAN5yHuOUUwUL6U6O0KEn4irSq4eF0hCqINX vKtm5HC3bx0VO7qyARClPhjbewZ9YRpvAptgJfbQxPPoNIs0H2D+B9mfioGDtTqU4N20 /oR0FX96tw5H2CmRupws9bZP7XMd0CaYikz69cXhiyEPZNRTp5CPcOMEKFS0jX/DAjzy FOhl0NTA0oHuO8c0JTUxTK9yIqlatnvzVJeHlheWZnYEja7a2zCUWHQ4F8VFnDTfGs9M Wv/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=ROOEbYjWJqHyCtkw2fZQEfd0qrZ/Q2rB06eeS8VmaU8=; b=tUhOudAVlwa4BMB3AY/6zDA0P9q6PaxJAYgcTki0Oc+UNyxccBUmbOPkyLhvj6U1o/ OVyGrfmZpCOgEzq0dWuRb5s53ASjPtv83vQ4vm8IngzgGf+5XZGaerIae61Lr8yDh8VM njBhwCyynhkRcZNvzcsXDYPHXOJD368QBnujrealIydMfvmMpksykDYyqFMmrFq2t3nC rV23wnuV52tNlZ11eFYoeOZw79POI74IUVbzoch1JxjEDJlll2AMJ/7yTmyfmy3LKSeN lV/oWV8gdgnHVaHCtqLtZkH+NTogqR1TaIqhaLOE1m6w4ikoRgymR2BhYF+W1isfkAbB uLJQ== X-Gm-Message-State: AOAM531LAkyQxOtlNuOLuoWhVyjTXsUq36YFOKC/qgKgEgchQOORkVWe VlSIHTDZ1MkcBNeq1HjU2pI= X-Google-Smtp-Source: ABdhPJw/9q3/NyJYJ3rb5Hg1U81FiqB87P0bWOrYhBrYvAJriPZs6OuuahkNbMxqwJFLsADdSJxWFQ== X-Received: by 2002:a63:181f:0:b0:3c6:b0d:2214 with SMTP id y31-20020a63181f000000b003c60b0d2214mr15045440pgl.60.1653192563129; Sat, 21 May 2022 21:09:23 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id w66-20020a628245000000b0050dc7628179sm4399569pfd.83.2022.05.21.21.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 May 2022 21:09:22 -0700 (PDT) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: [PATCH] Re: Bug in 9.5.3 org--file-default-apps In-Reply-To: References: <963d5f94-3fdf-a01b-bc91-edc99222cb34@gmail.com> <87czgeaxir.fsf@localhost> <6615610d-93ae-171f-b554-3f4cc79354cc@gmail.com> <87a6bhc1w6.fsf@localhost> <86692975-4d5f-6933-3227-c6b208f76862@gmail.com> <877d6lbsg5.fsf@localhost> <7c75b724-1ea2-5e3e-cbe6-e1895fd35bd3@gmail.com> <877d6j2htv.fsf@localhost> <87ilq14p6p.fsf@localhost> <87v8u0396t.fsf@localhost> <87ilpz3bi0.fsf@localhost> Date: Sun, 22 May 2022 12:10:05 +0800 Message-ID: <87h75ip5r6.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=yantar92@gmail.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653192606; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ROOEbYjWJqHyCtkw2fZQEfd0qrZ/Q2rB06eeS8VmaU8=; b=qSyOewfk2naWYm1AQ4SptkfkPFBcujixPgSh8xa+Gcgz/E0fvWf6S9vAVZmCalrkzEFKI1 31ApTw3W89JjHCtplZ0B3DDHTmHDC8pB7iGHsusA/M2llr1jY6eo0WpxwNVQO4AMCn2NIp buXcw6K0D/BPUVDJWXWifJGVRGRB11QCzVS9WQjDXjr6f406STc7Pwt2081/h5qeEapY4N 17KNqC/QgV9QdFDNRB0ccxDEJq7hzSbFnf9ro6cSdPmWL7J3Kw6VX/liM3+zdBTPDiLDov 5HPtE/iq6qhS1bf0bvFxtYV+H6l/9J2m1qFxSMgSGymWLa/RR78PR9m4aFhFJA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653192606; a=rsa-sha256; cv=none; b=I7MEHp138jaTc5VGcD5X9dtCopWWdGq5uhFCP+/CdH+zj9h7r9Y2KvoRDb2SPHYeQZ8g/9 nlqSh6fiNhzxoGu4/A8DFbXmqJaEPWxbxS4ZZUyJQAc4dJRajcDYlLDuD2QBcnKqcpQ49L zgL/DWu0eDyXIpocLipdVG4KUeblxPNGOy9VRiF1lW+QBYLGKysz5xuSMHBX24owiaQ5GG 0c06LEXEkEMzC1G1RxWb/cjgM2fvzFlYMFTOIIkRkv4SvggcYyeAV2dMwebWsZsyJ6w8+z MnjQjpN6R/Nc1lWIPasq8ngBDxTM9ENLRFJSFjEPwKMJ3j5/wniV6KuxkGJWMA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QHBDDoba; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -9.05 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=QHBDDoba; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 6A3CF6212 X-Spam-Score: -9.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: m+AhVXJVMj+4 --=-=-= Content-Type: text/plain Max Nikulin writes: > On 21/05/2022 08:44, Ihor Radchenko wrote: >> Max Nikulin writes: >> >>> It is the same with and without -Q and no, I have not customized >>> `mailcap-user-mime-data', its value is nil, easy customization interface >>> tells that it is the standard value. There is a chance that debian has >>> some patch, but most of debian specific is disabled when -Q option is used. >> >> Interesting. In any case, it confirms that mailcap behaviour depends on >> both Emacs settings and also system settings. > > You should be even more surprised, if I say that [[file:~/tstorg]] link > is opened in emacs buffer in shell-script mode (emacs-27.1, org main > HEAD) despite > > (mailcap-mime-info nil) > nil > > The source of the problem is that Emacs-27 was released with the > following bug: > > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=40247 > mailcap-mime-data erased when parsing mime parts > > So `mailcap-parse-mailcaps' called from `mailcap-mime-info' erases > predefined associations in Emacs-27. If I understand correctly, this extra complication does not affect most of the systems. I am not sure if we need to work around it. Also, I am attaching a patch to address the original issue. We can just use file command when available. WDYT? Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-open-file-Use-file-command-to-determine-mime-typ.patch >From f69824559d62cb6963ff30f11ceb46303bf1b3d4 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Sun, 22 May 2022 12:04:35 +0800 Subject: [PATCH] org-open-file: Use file command to determine mime type, when available * lisp/org.el (org-open-file): Prefer file command to determine file type instead of relying on `mailcap-extension-to-mime'. Only fallback to the latter when file command is not available on the system. Fixes https://list.orgmode.org/874k1n2hpv.fsf@localhost/T/#mcc10df4ea7937360671e6dea8061153dee518807 --- lisp/org.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/org.el b/lisp/org.el index d7da8efc4..3102fe611 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7975,7 +7975,12 @@ (defun org-open-file (path &optional in-emacs line search) (when (eq cmd 'mailcap) (require 'mailcap) (mailcap-parse-mailcaps) - (let* ((mime-type (mailcap-extension-to-mime (or ext ""))) + (let* ((mime-type (if (executable-find "file") + (shell-command-to-string + (format "%s --brief --mime-type %s" + (executable-find "file") + file)) + (mailcap-extension-to-mime (or ext "")))) (command (mailcap-mime-info mime-type))) (if (stringp command) (setq cmd command) -- 2.35.1 --=-=-=--