From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id aKZSNQ5dc2Q8lwAASxT56A (envelope-from ) for ; Sun, 28 May 2023 15:54:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 4H0XNQ5dc2RIngAA9RJhRA (envelope-from ) for ; Sun, 28 May 2023 15:54:22 +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 D216A16A19 for ; Sun, 28 May 2023 15:54:21 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3Gpv-0006vk-5a; Sun, 28 May 2023 09:53:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3Gpr-0006uD-GA for emacs-orgmode@gnu.org; Sun, 28 May 2023 09:53:27 -0400 Received: from mailxcu.skyguard.com.cn ([210.12.103.1] helo=smtp.secgator.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3Gpm-00075u-Sf for emacs-orgmode@gnu.org; Sun, 28 May 2023 09:53:27 -0400 Received: from mail.skyguard.com.cn (unknown [172.21.23.75]) by smtp.secgator.com (SkyGuard) with ESMTPS id 4QTg8w6s6Qz6KhG for ; Sun, 28 May 2023 21:53:04 +0800 (CST) Received: from [10.0.0.10] (unknown [111.196.130.232]) by mail.skyguard.com.cn (Postfix) with ESMTPSA id 4QTg8y2q04z2xDR for ; Sun, 28 May 2023 21:53:06 +0800 (CST) Message-ID: <7a012430-6084-e693-1a86-f14d0512bebc@skyguard.com.cn> Date: Sun, 28 May 2023 21:53:16 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Content-Language: en-US To: emacs-orgmode@gnu.org From: Pan Xie Subject: [FR] Please add environment variable substitution in `org-display-inline-images' Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=210.12.103.1; envelope-from=xiepan@skyguard.com.cn; helo=smtp.secgator.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SBL=0.141, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685282062; a=rsa-sha256; cv=none; b=Dbw/zvgNl9QFt86jO4sT1DWisnsBdRstJ5Ccz60aVWBHo1lklBY0x/xbSyE8jvEaPUP08R PVmyB+RbRiJobKooSCLBZe+AZpXQj0tYmN2J1xC4a8CGc4eTNAX9zLNL9IQJT5cZFVQH+p iR3yurwLZiocFvOFFnmQML6NwLnmnCAXNcCvCCyifMJPrYPAQzk+x2lgKx7mmcFMP3JzAg U3+ATFZpdSGDVUPwM/Lt+OxTbhN4mrPHX7S6GPq8DHjKC+LKWHTz2wm1oHmNCUkrPXGfWM EwCIjpIEkTX6ioBWbGPoccBgfcDyjIwcTmlq6dmZK56ylwqIpkLBONsGVfQFcw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685282062; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=92TiJbifxD2ZwfDGbAQIl6DFwwBW5+PkWndg+LsWg0U=; b=mHmA4yud1/DB5kHAKuCaA/+2JrERp5xOT3LKpLyjC6QvDTymczDzYsbtXNpZE5Inizxn03 CpazsGi1MDyH/WKD5XzW9GJKD7amh77Umnr9ePcGbknxQt1ZV3Htzuavc+QVTd0OSkDUX7 DMejaZLoO/E8xnkMu8RbcImFRA1pF/0048XXr1fd0ZUJkqQ3P9LhlNFmwNZ1OqiZ8x9l8Z /nm2/uDkQgsmKDPBX4YlvaylXKjTYWnGdA0hZ4sX/LwwKNh363fLoiGCqcE5DeAQuRIqmR TUG/xT5+qHpmsS5r3192+wJE9OcYGQYD/2Nnu0JZuX9V0CWWpjUZ2Uf7N+PMZg== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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: 0.35 X-Spam-Score: 0.35 X-Migadu-Queue-Id: D216A16A19 X-TUID: Im33hZC7k/OA Hello, I recently found that the environment variable substitution does not apply to inline image paths. Supposing I use a path “/home/pxie/$Gallery/” to store all my image files, “$Gallery” should be substituted with its corresponding value. The file link DOES substitute the environment variables, but inline image paths not. So I think it is a reasonable demand for the consistency. It is also very important for my and other users' (I strongly believe) configurations. Environment variable is the key abstraction to make the same org document works on different machines with different path hierarchies. I hunt down the codes and find just one line change can fix that. In `org-display-inline-images' function, add `substitute-in-file-name' to the `expand-file-name' call. I can override the function with the solution but I hope it can be added to the official codes. So my proposal of the code change would be (find "pxie" in the codes): #+begin_src elisp (defun org-display-inline-images (&optional include-linked refresh beg end)   "Display inline images. An inline image is a link which follows either of these conventions:   1. Its path is a file with an extension matching return value      from `image-file-name-regexp' and it has no contents.   2. Its description consists in a single link of the previous      type.  In this case, that link must be a well-formed plain      or angle link, i.e., it must have an explicit \"file\" type. Equip each image with the key-map `image-map'. When optional argument INCLUDE-LINKED is non-nil, also links with a text description part will be inlined.  This can be nice for a quick look at those images, but it does not reflect what exported files will look like. When optional argument REFRESH is non-nil, refresh existing images between BEG and END.  This will create new image displays only if necessary. BEG and END define the considered part.  They default to the buffer boundaries with possible narrowing."   (interactive "P")   (when (display-graphic-p)     (when refresh       (org-remove-inline-images beg end)       (when (fboundp 'clear-image-cache) (clear-image-cache)))     (let ((end (or end (point-max))))       (org-with-point-at (or beg (point-min))     (let* ((case-fold-search t)            (file-extension-re (image-file-name-regexp))            (link-abbrevs (mapcar #'car                      (append org-link-abbrev-alist-local                          org-link-abbrev-alist)))            ;; Check absolute, relative file names and explicit            ;; "file:" links.  Also check link abbreviations since            ;; some might expand to "file" links.            (file-types-re         (format "\\[\\[\\(?:file%s:\\|attachment:\\|[./~]\\)\\|\\]\\[\\(