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 ms0.migadu.com with LMTPS id UNpeCHQq9WHuAwAAgWs5BA (envelope-from ) for ; Sat, 29 Jan 2022 12:52:20 +0100 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 sEPjAHQq9WHpTwAAG6o9tA (envelope-from ) for ; Sat, 29 Jan 2022 12:52:20 +0100 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 798212948F for ; Sat, 29 Jan 2022 12:52:19 +0100 (CET) Received: from localhost ([::1]:33528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDmHC-00041K-NV for larch@yhetil.org; Sat, 29 Jan 2022 06:52:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDm13-0002Ze-42 for emacs-orgmode@gnu.org; Sat, 29 Jan 2022 06:35:38 -0500 Received: from [2607:f8b0:4864:20::531] (port=44978 helo=mail-pg1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDm11-0000XV-IA; Sat, 29 Jan 2022 06:35:36 -0500 Received: by mail-pg1-x531.google.com with SMTP id h23so7597918pgk.11; Sat, 29 Jan 2022 03:35:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OmqgNGMvco47JXTIopiLES+20EMNpuWV42DKiX3Kf3s=; b=JgnsP7pzeMi2XgNalP+5uTk1F8ytVKOcMxb86/zonUjmEefeJcv4cfG9z+1ikBzU4i +SgWlMCDdmdojuq6Wg3nYJIg8n8Sd1A7IK74Gdw61i3eDEH8sO+ruiCxdOuL806V8dwM 9p+qkP2YnQePVIZUrIbZayJenVr0Er96ByMfwIXDpUW5u2dNEdqZ9rxOogwHBbYcXUZF 3bjP0z+Ja7vBO1AI15hnuqX/roel+mBTrPKt8XN4lzPyQcxRFOMbqUsEoPjgZ2vpPS7D vH7uMIaSF4jE70BV/UjObOZpq4TpHGPCtYNXuGr/XdW3CIL7HLQrIF/Iiz7f++hzPVWq 0Leg== 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OmqgNGMvco47JXTIopiLES+20EMNpuWV42DKiX3Kf3s=; b=4uCJRZmhVTrSfHVggEsd9i0cOV2Hk/JkFIEZraiPeEIsQXh6FgelJPz1MPvfxW0t/N cc3qMaA5cVyG/F/As3IFKVFbIbjOwWX6knpOgYhP6YgfhwFT8q6bpqjs6UjQY/4GLxxx 7QCFM/INdITZJQEnhtpmlizxKT1GQkcOJOuBGGKkcty5mMnL5Bz3OPNX/TYVATrsc3c9 C4Fx9ysXYBOBL/EIjv9ulIfnOMLOGHiuTsrQWwRkNeIkxyAriAQ/2tMjhystlPmfdlRp JmnVI7C5RzIy3egOyv8Xjfsp1ks0r1TqHn0ct9Umz/1NxhLUKKzgEbxUBRpp4tTVN6nb PTJg== X-Gm-Message-State: AOAM532YDNQIymmXb7NyYD/5vOY033I+yPZm9+nRnes6W7LzxD+jj1T7 vrxQWcBXntVaYTh6Tcu+4M7GMur3CIHQhnbN X-Google-Smtp-Source: ABdhPJwetcVMUG3gl48xbUbWzIdXYbbqa9REjDCX3XC8ruHCAdjg7bqq5S1uL9mqAWkIjRoMIFAlHA== X-Received: by 2002:a63:5007:: with SMTP id e7mr9625477pgb.585.1643456133342; Sat, 29 Jan 2022 03:35:33 -0800 (PST) Received: from localhost ([209.95.60.92]) by smtp.gmail.com with ESMTPSA id k5sm13235549pfc.85.2022.01.29.03.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Jan 2022 03:35:32 -0800 (PST) From: Ihor Radchenko To: Bastien , Kyle Meyer , Nicolas Goaziou , Karl Voit , Christian Heinrich , emacs-orgmode@gnu.org Subject: [PATCH 10/35] Implement link folding Date: Sat, 29 Jan 2022 19:38:02 +0800 Message-Id: <149145640c25d2ae191ab87c7056e372f9904370.1643454546.git.yantar92@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: <87y2cvloay.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.34.1" Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::531 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=yantar92@gmail.com; helo=mail-pg1-x531.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, 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: , Cc: Ihor Radchenko Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643457139; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=05Rj8hxbJRuPlV9beEuYq3ndS4WgYdbdOZSnyM4YFgQ=; b=KftvPDtfYyigq89XAJvPuB15z1pYIoCSVdzFzdD9A+Z5cpeoAtbOyBzTAX053F+lF4i5rt woyl5BBoGWKomfbcetMBMHLi0ulvYI1z4HnlzV0tQXPIIY/qIIx1jsD5pZNahTX2W7W0v0 ZdHNnZYbBfBshG3smrM7QyVkyZIYPSZ4xhfVBat8rU9Rp7t7iZpwk/vSCQ3I23H3LiSgMp aGndku5tC94MqSYq/kMFi/Qx0Wa5USMTSxdUaeqsjFIlSZ0FZsVFRFR0IA2ZCJmjieJVGo BdL8pGVXJYxll5/+6icefovgBfHuNyKQs1Tj5UCAztr4UQSK8sW5qfTxPN+SRQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643457139; a=rsa-sha256; cv=none; b=KbP196TBSfHYCDL8/t7pD2U9PT1v6WJDN6ZEN4rrTQmSnTkS+/rbOjmP0mBQphVDsppAA2 Pig3zdEE5IfWFszvrbLHazxgSuQz4EiLgzBDjjXRu10vUbJDFqHoFR1PQ9mQhOLbVnE8Sb bfJz6HCKMzGuEJZy2tnJw40Fj9GVmqiZBXJa0jMkzH+VDmdZ3oBOgzCU6meTY+jH5S8sdX OMCPb/MVym4d6vukilEzbdsa03VuCmVXy1vcYWeSsvrbBy4oc1jTYon8qjG1GjrYBFySRU buq4EB1Ws/16xKpYneSpvxhYAJUMFEWpwCJrd9LSGWxK2RvzFrfNdK77FJ3NAA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=JgnsP7pz; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: -1.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=JgnsP7pz; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Queue-Id: 798212948F X-Spam-Score: -1.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: hT08Syt2ujkf This is a multi-part message in MIME format. --------------2.34.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit * lisp/ol.el (org-link--link-folding-spec): (org-link--description-folding-spec): New variables controlling link folding settings. (org-link--reveal-maybe): Handle revealing folded links. (org-link-descriptive-ensure): Implement `org-link-descriptive' support with org-fold. (org-toggle-link-display--overlays): (org-toggle-link-display--text-properties): (org-toggle-link-display): Provide text-properties and overlays versions. * lisp/org-agenda.el (org-agenda-mode): Use org-fold to fold links in agenda. * lisp/org.el (org-do-emphasis-faces): Use org-fold. --- lisp/ol.el | 42 +++++++++++++++++++++++++++++++++++++++++- lisp/org-agenda.el | 3 ++- lisp/org.el | 11 +++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) --------------2.34.1 Content-Type: text/x-patch; name="0010-Implement-link-folding.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0010-Implement-link-folding.patch" diff --git a/lisp/ol.el b/lisp/ol.el index 21bd854e9..1837bf37c 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -605,6 +605,22 @@ (defvar org-link--insert-history nil (defvar org-link--search-failed nil "Non-nil when last link search failed.") + +(defvar-local org-link--link-folding-spec '(org-link + (:global t) + (:ellipsis . nil) + (:isearch-open . t) + (:fragile . org-link--reveal-maybe)) + "Folding spec used to hide invisible parts of links.") + +(defvar-local org-link--description-folding-spec '(org-link-description + (:global t) + (:ellipsis . nil) + (:visible . t) + (:isearch-open . nil) + (:fragile . org-link--reveal-maybe)) + "Folding spec used to reveal link description.") + ;;; Internal Functions @@ -762,6 +778,13 @@ (defun org-link--normalize-string (string &optional context) (t nil)))) string)) +(defun org-link--reveal-maybe (region _) + "Reveal folded link in REGION when needed. +This function is intended to be used as :fragile property of a folding +spec." + (org-with-point-at (car region) + (not (org-in-regexp org-link-any-re)))) + ;;; Public API @@ -1444,14 +1467,31 @@ (defun org-previous-link () (interactive) (org-next-link t)) +(defun org-link-descriptive-ensure () + "Toggle the literal or descriptive display of links in current buffer if needed." + (if org-link-descriptive + (org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible nil) + (org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible t))) + ;;;###autoload -(defun org-toggle-link-display () +(defun org-toggle-link-display--overlays () "Toggle the literal or descriptive display of links." (interactive) (if org-link-descriptive (remove-from-invisibility-spec '(org-link)) (add-to-invisibility-spec '(org-link))) (org-restart-font-lock) (setq org-link-descriptive (not org-link-descriptive))) +(defun org-toggle-link-display--text-properties () + "Toggle the literal or descriptive display of links in current buffer." + (interactive) + (setq org-link-descriptive (not org-link-descriptive)) + (org-link-descriptive-ensure)) +(defsubst org-toggle-link-display () + "Toggle the literal or descriptive display of links." + (interactive) + (if (eq org-fold-core-style 'text-properties) + (org-toggle-link-display--text-properties) + (org-toggle-link-display--overlays))) ;;;###autoload (defun org-store-link (arg &optional interactive?) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 2802e8636..063da6566 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2325,7 +2325,8 @@ (defun org-agenda-mode () org-agenda-show-log org-agenda-start-with-log-mode org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode)) (add-to-invisibility-spec '(org-filtered)) - (add-to-invisibility-spec '(org-link)) + (org-fold-core-initialize `(,org-link--description-folding-spec + ,org-link--link-folding-spec)) (easy-menu-change '("Agenda") "Agenda Files" (append diff --git a/lisp/org.el b/lisp/org.el index ebc9d81db..5465ed3ea 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4562,9 +4562,16 @@ (define-derived-mode org-mode outline-mode "Org" (setq-local org-mode-loading t) (org-load-modules-maybe) (org-install-agenda-files-menu) - (when org-link-descriptive (add-to-invisibility-spec '(org-link))) + (when (and org-link-descriptive + (eq org-fold-core-style 'overlays)) + (add-to-invisibility-spec '(org-link))) + (org-fold-initialize (or (and (stringp org-ellipsis) (not (equal "" org-ellipsis)) org-ellipsis) + "...")) (make-local-variable 'org-link-descriptive) - (add-to-invisibility-spec '(org-hide-block . t)) + (when (eq org-fold-core-style 'overlays) (add-to-invisibility-spec '(org-hide-block . t))) + (if org-link-descriptive + (org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible nil) + (org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible t)) (setq-local outline-regexp org-outline-regexp) (setq-local outline-level 'org-outline-level) (setq bidi-paragraph-direction 'left-to-right) --------------2.34.1--