From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxim Nikulin Newsgroups: gmane.emacs.bugs Subject: bug#12972: 24.3.50; Move `org-open-file' and associated code out of Org mode Date: Wed, 2 Jun 2021 23:20:50 +0700 Message-ID: References: <87r1hmdqek.fsf__16088.3597027109$1622530682$gmane$org@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1803"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 Cc: Lars Ingebrigtsen , 12972@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 02 19:24:05 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1loUb6-0000GU-Of for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Jun 2021 19:24:04 +0200 Original-Received: from localhost ([::1]:59816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1loUb5-0006TR-O5 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Jun 2021 13:24:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1loUFm-0006F8-VC; Wed, 02 Jun 2021 13:02:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57945) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1loUFm-00045w-Ne; Wed, 02 Jun 2021 13:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1loUFm-0000pU-Jn; Wed, 02 Jun 2021 13:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Maxim Nikulin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, emacs-orgmode@gnu.org Resent-Date: Wed, 02 Jun 2021 17:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12972 X-GNU-PR-Package: emacs,org-mode Original-Received: via spool by 12972-submit@debbugs.gnu.org id=B12972.16226532773122 (code B ref 12972); Wed, 02 Jun 2021 17:02:02 +0000 Original-Received: (at 12972) by debbugs.gnu.org; 2 Jun 2021 17:01:17 +0000 Original-Received: from localhost ([127.0.0.1]:41258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1loUF2-0000oD-I2 for submit@debbugs.gnu.org; Wed, 02 Jun 2021 13:01:16 -0400 Original-Received: from mail-lf1-f50.google.com ([209.85.167.50]:33707) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1loTc3-00088f-Ki for 12972@debbugs.gnu.org; Wed, 02 Jun 2021 12:21:00 -0400 Original-Received: by mail-lf1-f50.google.com with SMTP id a5so4332755lfm.0 for <12972@debbugs.gnu.org>; Wed, 02 Jun 2021 09:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:cc:newsgroups:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ya6aiAJD1Igr7jXa0vozrMZXAQMuRezgtp9or/ZTaHk=; b=GfgBSFK2M864EGQMvpikhFcKgAK+XD7eWmuUPgJAqZ46KdtHnjx3M//I4emkzxL7uy SihkRpLrseM6wbZp+F0nzo0W7nyrCQvrmLmZybgPWxZ7lecrG5YmoB0CcF9JFQKqSCeR Ql+Th7yIFk9btuA2dxihoZ5hrkgan25B4UJrPZCE7pwJUsB9OQPj36kAIp5AgSMoepIs qMf6vHKcwpOjU/LoPJxuDfk1NV7dpVWLUx1JMlOPNJxSOCifkxN6NP6eNFfkMN5Jrtvu 15hmHoMQ1Hmd6OYLLfiSSFAzJFYI9vCE7nvFvic0ZmGr89D8xydWwb+CK+XzBGClQ5kD c3LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:cc:newsgroups:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=ya6aiAJD1Igr7jXa0vozrMZXAQMuRezgtp9or/ZTaHk=; b=rAPnfiLWf+rmaKHQ4+tvdbgc9ofuFNvkFz7nUaW7U10T8zmk6LVRumpBnPDqwKHfLz sNYzPHYKYcnVO6tKA19gpNv5x3eJ5Oef6WyA7DLW6XuP3xY+svMqCwUp9AC6Ep/w/zN8 Fx4XYZvLehP3KuKxV4zPOzcsDKNbbosbgfY2XWQnuqOpXKQo4iUxsIXVQuS/78JXShuw kXMK+kqzzM6Mhpy/GX5Vg3nQ1cj+4r7Wx7fJzwuH0qEAW5j1f9gFqpvpWTGp0Nz/np5/ xjTExK2//efkduxR8Z8AxJP++SUIk9E/BubZfTBeaAJ4S3otpYlq+AE0e/ioyGe71utm 1X9A== X-Gm-Message-State: AOAM5303wqqhFBj+Z8qTG2UPtmpexZR8ux0BGDp/EXIDb+iShko64ZeQ HaIJZvt8u8NkN+L6IPMdxACXWc2nQc7bH8lk X-Google-Smtp-Source: ABdhPJznkwmT2mn8gtwNUtYO3OU2D0UybQb/hjCUJpNTEGzVXGEbKPBydAXse2rb4lOuP99ZRgNZAA== X-Received: by 2002:a19:4086:: with SMTP id n128mr23375429lfa.464.1622650853647; Wed, 02 Jun 2021 09:20:53 -0700 (PDT) Original-Received: from [192.168.0.101] (nat-32-4.nsk.sibset.net. [5.44.168.126]) by smtp.googlemail.com with ESMTPSA id h19sm28036ljk.138.2021.06.02.09.20.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Jun 2021 09:20:52 -0700 (PDT) Original-Newsgroups: gmane.emacs.orgmode In-Reply-To: <87r1hmdqek.fsf__16088.3597027109$1622530682$gmane$org@gnus.org> Content-Language: en-US X-Mailman-Approved-At: Wed, 02 Jun 2021 13:01:14 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Wed, 02 Jun 2021 13:23:58 -0400 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:207877 Archived-At: On 01/06/2021 13:56, Lars Ingebrigtsen wrote: > So I've now added this to Emacs 28 under the name > `mailcap-view-file'. I am sorry if it is a false alarm. Feel free to close the bug again if something changed recently in `start-process-shell-command' or if you prefer to discuss the issue as another bug. It seems that implementation of `mailcap-view-file' is unreliable due to creation of unnecessary terminal session and it can cause obscure and difficult to reproduce failures similar to https://lists.gnu.org/archive/html/emacs-orgmode/2020-09/msg00195.html https://lists.gnu.org/archive/html/emacs-orgmode/2020-06/msg00332.html The thread is actually longer than it is shown in the archive interface. Another lengthy discussion: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=44824 In Org latest change was required for compatibility reason: https://code.orgmode.org/bzg/org-mode/commit/869b7a21b94ed112f6640c8f2711c2a68b661dea Let-bind (process-connection-type nil) is a minimal required change to avoid unnecessary terminal session. However it is not friendly to users in the case when troubleshooting is required. `make-process' with sentinel is hopefully better. The following could be ignored since it likely requires significant amount of work with unclear benefits. 1. `org-open-file' besides Org-specific stuff allows to specify precise target inside the file. It can be quite useful, e.g. okular --page 11 --find "some pattern" file.pdf PDF files have internal anchors as well. I have no consistent vision how to express additional "locators" in general API. 2. There are at least two sources of truth for MIME-handlers on linux desktop that are not necessary synchronized. Info from extracted from .desktop files may be configurable from desktop UI unlike mailcap. Distros may have some instruments to mitigate discrepancies. Debian adds entries from .desktop handlers to system-wide mailcap DB. Another approach is to add to maicap greedy xdg-open handler that tries to guess currently running desktop and pass arguments to appropriate command. Maybe mailcap should be secondary MIME database in Emacs, not the primary one. 3. Currently only file suffix is inspected to determine MIME type of a file. libmagic (or file command) usually provides more precise info, so it is possible to open an incorrectly named file. 4. Mailcap has more features that are not addressed in Emacs. They may be handy if Emacs is launched in terminal on remote server. It might allow e.g. to open PDF file using pdftotext handler. - A buffer for command output should be created for "copiousoutput" option. - A buffer should be created and terminal session should be enabled if an entry "needsterminal". - There are more substitutions than "%s". However I am unsure if it is possible to provide more info than application can obtain from the file. I think, it is intended for mail multipart messages and additional headers. On the other hand mailcap handlers might expect safe file names (minimal ASCII subset), users may have files with arbitrary names (national charset or some special characters). I hope, almost all handlers do not have such problem. In summary, during launch of external command terminal session must be suppressed. There is enough room for MIME-related improvements in Emacs in general and in Org mode in particular.