From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id yHuJNzzyEWMbAQEAbAwnHQ (envelope-from ) for ; Fri, 02 Sep 2022 14:08:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id WL2VNjzyEWOOJQAAG6o9tA (envelope-from ) for ; Fri, 02 Sep 2022 14:08:28 +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 6C6AB3B252 for ; Fri, 2 Sep 2022 14:08:27 +0200 (CEST) Received: from localhost ([::1]:55838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oU5TF-00020N-Mb for larch@yhetil.org; Fri, 02 Sep 2022 08:08:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU5SF-0001zz-W6 for emacs-orgmode@gnu.org; Fri, 02 Sep 2022 08:07:24 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:36382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oU5SE-000818-3q for emacs-orgmode@gnu.org; Fri, 02 Sep 2022 08:07:23 -0400 Received: by mail-pj1-x1032.google.com with SMTP id z3-20020a17090abd8300b001fd803e34f1so5306643pjr.1 for ; Fri, 02 Sep 2022 05:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date; bh=yPl6Zxvh2KCx+NaKIMO/mDiQzaAub1/1MhVMCzYlVf4=; b=Zm3ZGK6UtZua87pBlsym8Tjp+sHaLdVa6T3qsKLprxTLVYjYMLy02mlAADtgro/8sr qj3kfommMMkUVCbU81sAeAmhIQYdhbEz/grgjuYBBMcJKRZy51bHMUUhEz/uwcMrkWtd 0H+l4MO3aAHI0Lsd8681ry6K2go36+XMd38Sf5jM2UZJxUjmHW/tWtynlZPWZzKOhwz/ Hp3CHvsqU8nBX1Bu2fhA8EOfgMWPyg9bfmdxK6bvYDKFaShdp1xb7u1LKxwkjXUKNF0c 6ZODTAQYuGqIr5WwW5cJCQaQEBFVrr1fcsoHepZAQ4pByS32hdgrR1CaJv4aw7jbUuQ9 FXtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date; bh=yPl6Zxvh2KCx+NaKIMO/mDiQzaAub1/1MhVMCzYlVf4=; b=aTVLeTWScgYbyLTuEgxxCQskrLV4sA0PHezumx9SvF+NoJXGMf+046y6UPHmNaYUk7 9Ju2skbSJnYldnCAzhFg736gh8ofYjcgvFovYRWNq/0Y8rokooDQDnaiXv4DR6R4bUqV dH26+rCNu/Ihn89xogNYt99LUSsZEd7xiDXMH42TLZ+VnipKnM++LEjZNC0XGjQA4gQt 24I4dcERLL+5X7gAGOLdRYRlgvDiivdDXv9BI4FkowSqYjzJgZkLKo7W8F9HrCDZObnc fEehgxgyVAsOQgTlzS+OSiU6Ks8prnnN1OmcHVvOI+FLtiIblpW9SnA75dmTBO/JSVLy h1Zg== X-Gm-Message-State: ACgBeo1HbOZdgdG8HyT1Gb6cVeAVzhwCnTXcN70LV4b9nAvgJ5wRERyL X8Sw1QRbXlJaViorba7nFD4= X-Google-Smtp-Source: AA6agR7RUa8znA9bo7Z8eFcasYzAKPpG7Vxi9hQLcVanzCP7jhQA8OjVa+fudsxWy4AP6hCQl7d0NA== X-Received: by 2002:a17:90b:4f44:b0:1fa:f63c:ea1b with SMTP id pj4-20020a17090b4f4400b001faf63cea1bmr4744399pjb.30.1662120440185; Fri, 02 Sep 2022 05:07:20 -0700 (PDT) Received: from localhost ([2409:8a70:2b2:5800:8ec6:81ff:fe70:339d]) by smtp.gmail.com with ESMTPSA id u2-20020a170902714200b00174a5e1afe9sm1443884plm.114.2022.09.02.05.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 05:07:19 -0700 (PDT) From: Ihor Radchenko To: Max Nikulin Cc: emacs-orgmode@gnu.org, Kyle Meyer Subject: Re: [PATCH] org.el: Fix percent substitutions in `org-open-file' In-Reply-To: References: <874kih92nb.fsf@kyleam.com> <87mtw8fupl.fsf@kyleam.com> Date: Fri, 02 Sep 2022 20:08:17 +0800 Message-ID: <87tu5qm11q.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=yantar92@gmail.com; helo=mail-pj1-x1032.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=1662120507; 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=yPl6Zxvh2KCx+NaKIMO/mDiQzaAub1/1MhVMCzYlVf4=; b=LRgogBzhEcU8bHTwDL9DVOHs6LLxVNmvP68UNMYcDTquluB+07kUcDnwA1Gw8qJuFg6tB9 XKaCXzyu/Uj7au747sfXbDouEsoz4Ss056a3JAnIi1397lrd63iO8UPGzneEX009OLEG4S +Hs+L/Ve5ePFOgugH/sQPYvaKxri71oqV1tiX3YJw80fYvnqJqD6ApsnMu7pFuDUTMC+fF cM7+lDxY/wKSh8Bfn19Y/fSyjNGSZ5lOVliR90Zw491TZUkFsWPdiv67OcG5WNbi3dLK36 mK7xFe3NUPs5D5IF016DOoRS2yJFRDNdk7sq878PYgJXs6WBKk+vEAmmjeVEOQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1662120507; a=rsa-sha256; cv=none; b=SNQ54JXfrXjtv3MRecpxbhM06t2C9lOkF3D+G5n4VSSqB06w4m+IG0nTxdVO50HBaF1ePD /ZLDF2OoMd8rzTR+tQyX80AqKlBD9zjzB7rpF/w1kTrjIOV5VzjO/VDK+dYVSH4TFRAhR1 luofBlVgdX9hsd6SglrSDa+uzTPlsPWwhQ5AIB7C/YJdOHL1wk5pzjzy7f9Q5v61EVp4vU vO/Eocv3iUEbrFmINfOlqSr2A+VY0K3vP98yzQzSsLiJRTBQDcD/K23+VV+YDrJ92rdidV Y9RkEha3CyycTEUE0fRoeeoZQbkcvopius8+qibnljtnlNCe0XH7rA5J8qQ+mQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Zm3ZGK6U; 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: -1.77 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Zm3ZGK6U; 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: 6C6AB3B252 X-Spam-Score: -1.77 X-Migadu-Scanner: scn1.migadu.com X-TUID: lqsf69hyuHV0 Max Nikulin writes: > It's pity that this issue has not fix yet. I have tried to implement > another helper function. It is hardly usable outside of `org-open-file' > (perhaps it is still suitable to make mailcap commands), but separate > function makes the code testable. I hope, the attached patch fixes the > problems with multiple regexp groups and with percent characters in > replacement string. Notice that "\%", not "%%" is used to escape percent > in mailcap, anyway neither variant was supported before. > From 2f2850dcdc0cba8cfc6c0e21fc893c4e664d575c Mon Sep 17 00:00:00 2001 > From: Max Nikulin > Date: Sat, 27 Aug 2022 23:51:24 +0700 > Subject: [PATCH] org.el: Fix percent substitutions in `org-open-file' Thanks! LGTM, except one comment. > +(defun org--open-file-format-command > + (mailcap-command file link match-data) > + "Format MAILCAP-COMMAND to launch viewer for FILE. > + > ... > +For example, to specify particular location withing a PDF file, > +`org-file-apps' list may have the following entries (order is important): > + > + ;; Page and search string, > + ;; e.g. . > + (\"\\\\.pdf::\\\\([0-9]+\\\\)::\\\\(.+\\\\)\\\\\\='\" > + . \"okular --page %1 --find %2 %s\") > + ;; Internal anchor and search string, > + ;; e.g. . > + (\"\\\\.pdf::\\\\(.+\\\\)::\\\\(.+\\\\)\\\\\\='\" > + . \"okular --find %2 file://%s\\\\\\\\#%1\") > + ;; Page number, e.g. . > + (\"\\\\.pdf::\\\\([0-9]+\\\\)\\\\\\='\" . \"okular --page %1 %s\") > + ;; Internal reference, e.g. . > + (\"\\\\.pdf::\\\\(.+\\\\)\\\\\\='\" . \"okular file://%s\\\\\\\\#%1\") > + ;; No location within the file, optionally followed by \"::\", > + ;; e.g. . > + (\"\\\\.pdf\\\\(?:::\\\\)?\\\\\\='\" . \"okular %s\") This is a nice set of examples, but it probably does not belong to this docstring. I'd rather see this in `org-file-apps' docstring or even in the manual. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92