From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 eDT5E/cNYGJ1FQEAbAwnHQ (envelope-from ) for ; Wed, 20 Apr 2022 15:43:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id sFbWE/cNYGJ2zQAAauVa8A (envelope-from ) for ; Wed, 20 Apr 2022 15:43:19 +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 E24482B0E9 for ; Wed, 20 Apr 2022 15:43:18 +0200 (CEST) Received: from localhost ([::1]:53140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhAc1-0006OX-Sh for larch@yhetil.org; Wed, 20 Apr 2022 09:43:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhAKj-0004JX-0n for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:25:27 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:39428) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhAKa-0003wo-4J for emacs-orgmode@gnu.org; Wed, 20 Apr 2022 09:25:21 -0400 Received: by mail-pl1-x62a.google.com with SMTP id c12so1764284plr.6 for ; Wed, 20 Apr 2022 06:25:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:in-reply-to:references:message-id:date:mime-version; bh=cP8dYNgCEo51LvWmc6c1hEdGlBZENVmP+1Ggr3uBF9A=; b=X7z+c81kq1Lkd+Kp0zZAX5SjO75Uompf61HQ8Q+xMyYZOuelbH0MDNIXy5GNNYEQze II1aIuxD8J984bcfWwLAF+STFgiHTtVhXnEG02ow9grDNtaj1kyLuS4f/o3LTbedK5zk ZsNeSSBNJdRc222yvuLhAObDSjIQYMEsQU90xXFgdfqq1hA0lsjGa6wVi/lS/KQIByh2 6rduuZ+Mfd858SkoX4Al67yCPYbRMa/Vno5tOnwSwCOcNcW2WcO+CQkroaUuGamiKiNW Qt94rZhnsBbD7iyVedW+O/2aZKCCUwK4y0kvPbeCEzxRI1M1/FbYiRoQDk6okqv/K4fY Ur6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:in-reply-to:references :message-id:date:mime-version; bh=cP8dYNgCEo51LvWmc6c1hEdGlBZENVmP+1Ggr3uBF9A=; b=IlGSdJN9d1S//xQQwaj1ovsPdY4PENTFkxVttroNTsd7hwUF7YAEMeCDLlwsFurXBx vtI0RTeGnPuuLyn01TOpvjBz6CuHJbzdlK5g3vxfPVDtsNmRq5fFmt+4bXUGG2685UT6 ocMEwgNqeOEcQJl0f7fnQOj0VZ/DT1pf2p6obP7c0hE+zj4OF2IfdCcOmb+dVZCLxo9l yt/YokwTZ8J/r1i+TGZYynLGUJIkNBfW6TM6vNcRzlwU5oJoAodmgUY4z6ZdH5TUP6KB lh2Fa6Lrq0qA9HM0VAQadRHezaLRpaCdu3O78kfwOgxM8N+ehUT1cqeyTfNZivoVEpEx REjA== X-Gm-Message-State: AOAM532whg4lQVLQrIazY6giTK3DXHNKJ+tloDMuEiCCaKH9eg1f8bIs 42AVeRAmJOIA+qGBCqFDhaWZxCWsSmOmCw== X-Google-Smtp-Source: ABdhPJyc7ClE38l7XdMN1HLpewe6/9tM8ZhlWWSJ9c9ZD8SKsDqX1MyXXWAYtHizq4uUoxUOw4aVOw== X-Received: by 2002:a17:90b:4f82:b0:1d1:b8fd:7e36 with SMTP id qe2-20020a17090b4f8200b001d1b8fd7e36mr4484298pjb.194.1650461112111; Wed, 20 Apr 2022 06:25:12 -0700 (PDT) Received: from localhost ([64.32.23.62]) by smtp.gmail.com with ESMTPSA id ch10-20020a056a00288a00b0050a51a95e91sm14366403pfb.201.2022.04.20.06.25.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 06:25:11 -0700 (PDT) From: Ihor Radchenko To: emacs-orgmode@gnu.org Subject: [PATCH v2 17/38] org-compat: Work around some third-party packages using outline-* functions In-Reply-To: References: Message-Id: Date: Wed, 20 Apr 2022 21:26:05 +0800 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=yantar92@gmail.com; helo=mail-pl1-x62a.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=1650462199; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=cP8dYNgCEo51LvWmc6c1hEdGlBZENVmP+1Ggr3uBF9A=; b=ELT6eiVBRODi6BP/+icGYbi59wkRROJkYfSG4K2WPKabAJEqEaEQoZATrfEH+dwl3FpI2P UDBTyawf6qMVlMdZR8rdbJHCKgT+nmELnEFVKMewfdT3cGEZaVG5/ARta5kDrP6xp8ycnu zscbbMYlso1YfThTCgGrWF1RbbmnFY6RBrEuvEk0AJlw+dkUr3f0B5iFjjcSSXY4hHT60x OE+SosDtG9yi2nqXZTFy3QZSFWV/5IxppFhQ6U52yQlujqsjbv9aBuum5mV3VxgZP4o9m3 rW8GRpRBc+z7SSkdJWQfbIdL8IPhbV2/gLSZSo+R6uYQrOL6Prp5ArXoaQmqRQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1650462199; a=rsa-sha256; cv=none; b=T3FgQfIY0FYmpN8eOEYeALQOJGxRsZS0ImopcNgiEb2wVo7k28f6t1JfTPG1i3OQ/aq/jl jvYfHWFGzsxlteJsvjS+nFhl7V7MzLgg8b+a+fFcKfsGKaoU3BIt/CyMogg43VubGXiOBL vh0OLJ/Ts3O+G/+ZSJ1/LI/JkBLi4zlWdvvJZAFo7maHPG4uhIgcga1MPhnYQDuVIZAA06 L5YvIl9XL9ClSPqbM6Ts5rDNbecQyw1xoaFAfZuM1FEt1tMoJ9STfI6eg+yxN1bpLkSB4S vYnB2eNcxEHXJ0/vDecbHS1MChgI8NyfbKDGmTnoHop/R/Vkhgan1WKZw6PM9g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=X7z+c81k; 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: -3.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=X7z+c81k; 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: E24482B0E9 X-Spam-Score: -3.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: Z5uijSiFn1gu --- lisp/org-compat.el | 72 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index 3e8f49f0a..f599e246e 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -1330,11 +1330,81 @@ (defvar session-globals-exclude) (eval-after-load 'session '(add-to-list 'session-globals-exclude 'org-mark-ring)) +;;;; outline-mode + +;; Folding in outline-mode is not compatible with org-mode folding +;; anymore. Working around to avoid breakage of external packages +;; assuming the compatibility. +(defadvice outline-flag-region (around outline-flag-region@fix-for-org-fold (from to flag) activate) + "Run `org-fold-region' when in org-mode." + (if (eq major-mode 'org-mode) + (setq ad-return-value (org-fold-region (max from (point-min)) (min to (point-max)) flag 'headline)) + ad-do-it)) + +(defadvice outline-next-visible-heading (around outline-next-visible-heading@fix-for-org-fold (arg) activate) + "Run `org-next-visible-heading' when in org-mode." + (interactive "p") + (if (eq major-mode 'org-mode) + (setq ad-return-value (org-next-visible-heading arg)) + ad-do-it)) + +(defadvice outline-back-to-heading (around outline-back-to-heading@fix-for-org-fold (&optional invisible-ok) activate) + "Run `org-back-to-heading' when in org-mode." + (if (eq major-mode 'org-mode) + (setq ad-return-value + (progn + (beginning-of-line) + (or (org-at-heading-p (not invisible-ok)) + (let (found) + (save-excursion + (while (not found) + (or (re-search-backward (concat "^\\(?:" outline-regexp "\\)") + nil t) + (signal 'outline-before-first-heading nil)) + (setq found (and (or invisible-ok (not (org-fold-folded-p))) + (point))))) + (goto-char found) + found)))) + ad-do-it)) + +(defadvice outline-on-heading-p (around outline-on-heading-p@fix-for-org-fold (&optional invisible-ok) activate) + "Run `org-at-heading-p' when in org-mode." + (if (eq major-mode 'org-mode) + (setq ad-return-value (org-at-heading-p (not invisible-ok))) + ad-do-it)) + +(defadvice outline-hide-sublevels (around outline-hide-sublevels@fix-for-org-fold (levels) activate) + "Run `org-fold-hide-sublevels' when in org-mode." + (interactive (list + (cond + (current-prefix-arg (prefix-numeric-value current-prefix-arg)) + ((save-excursion (beginning-of-line) + (looking-at outline-regexp)) + (funcall outline-level)) + (t 1)))) + (if (eq major-mode 'org-mode) + (setq ad-return-value (org-fold-hide-sublevels levels)) + ad-do-it)) + +(defadvice outline-toggle-children (around outline-toggle-children@fix-for-org-fold () activate) + "Run `org-fold-hide-sublevels' when in org-mode." + (interactive) + (if (eq major-mode 'org-mode) + (setq ad-return-value + (save-excursion + (org-back-to-heading) + (if (not (org-fold-folded-p (line-end-position))) + (org-fold-hide-subtree) + (org-fold-show-children) + (org-fold-show-entry)))) + ad-do-it)) + +;; TODO: outline-headers-as-kill + ;;;; Speed commands (make-obsolete-variable 'org-speed-commands-user "configure `org-speed-commands' instead." "9.5") - (provide 'org-compat) ;; Local variables: -- 2.35.1 -- Ihor Radchenko, PhD, Center for Advancing Materials Performance from the Nanoscale (CAMP-nano) State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong University, Xi'an, China Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg