[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 0c055d2d31 1/3: org-compat: Add forward-compatibili
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 0c055d2d31 1/3: org-compat: Add forward-compatibility for argument changes in adviced functions |
Date: |
Tue, 6 Sep 2022 09:57:59 -0400 (EDT) |
branch: externals/org
commit 0c055d2d319e5a81456038bdfa8e31e57398ec47
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
org-compat: Add forward-compatibility for argument changes in adviced
functions
* lisp/org-compat.el (outline-flag-region):
(outline-next-visible-heading):
(outline-back-to-heading):
(outline-on-heading-p):
(outline-hide-sublevels):
(outline-toggle-children): Accept arbitrary extra arguments and pass
them to original function if its arglist changes in future.
This patch is following the "no-breakage" policy:
>> I won't break your user experience.
https://bzg.fr/en/the-software-maintainers-pledge/
---
lisp/org-compat.el | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 4a0309acd4..09f26e7353 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -1469,19 +1469,23 @@ key."
;; Folding in outline-mode is not compatible with org-mode folding
;; anymore. Working around to avoid breakage of external packages
;; assuming the compatibility.
-(define-advice outline-flag-region (:around (oldfun from to flag)
fix-for-org-fold)
+(define-advice outline-flag-region (:around (oldfun from to flag &rest extra)
fix-for-org-fold)
"Run `org-fold-region' when in org-mode."
(if (derived-mode-p 'org-mode)
(org-fold-region (max from (point-min)) (min to (point-max)) flag
'headline)
- (funcall oldfun from to flag)))
+ ;; Apply EXTRA to avoid breakages if adviced function definition
+ ;; changes.
+ (apply oldfun from to flag extra)))
-(define-advice outline-next-visible-heading (:around (oldfun arg)
fix-for-org-fold)
+(define-advice outline-next-visible-heading (:around (oldfun arg &rest extra)
fix-for-org-fold)
"Run `org-next-visible-heading' when in org-mode."
(if (derived-mode-p 'org-mode)
(org-next-visible-heading arg)
- (funcall oldfun arg)))
+ ;; Apply EXTRA to avoid breakages if adviced function definition
+ ;; changes.
+ (apply oldfun arg extra)))
-(define-advice outline-back-to-heading (:around (oldfun &optional
invisible-ok) fix-for-org-fold)
+(define-advice outline-back-to-heading (:around (oldfun &optional invisible-ok
&rest extra) fix-for-org-fold)
"Run `org-back-to-heading' when in org-mode."
(if (derived-mode-p 'org-mode)
(progn
@@ -1497,21 +1501,27 @@ key."
(point)))))
(goto-char found)
found)))
- (funcall oldfun invisible-ok)))
+ ;; Apply EXTRA to avoid breakages if adviced function definition
+ ;; changes.
+ (apply oldfun invisible-ok extra)))
-(define-advice outline-on-heading-p (:around (oldfun &optional invisible-ok)
fix-for-org-fold)
+(define-advice outline-on-heading-p (:around (oldfun &optional invisible-ok
&rest extra) fix-for-org-fold)
"Run `org-at-heading-p' when in org-mode."
(if (derived-mode-p 'org-mode)
(org-at-heading-p (not invisible-ok))
- (funcall oldfun invisible-ok)))
+ ;; Apply EXTRA to avoid breakages if adviced function definition
+ ;; changes.
+ (apply oldfun invisible-ok extra)))
-(define-advice outline-hide-sublevels (:around (oldfun levels)
fix-for-org-fold)
+(define-advice outline-hide-sublevels (:around (oldfun levels &rest extra)
fix-for-org-fold)
"Run `org-fold-hide-sublevels' when in org-mode."
(if (derived-mode-p 'org-mode)
(org-fold-hide-sublevels levels)
- (funcall oldfun levels)))
+ ;; Apply EXTRA to avoid breakages if adviced function definition
+ ;; changes.
+ (apply oldfun levels extra)))
-(define-advice outline-toggle-children (:around (oldfun) fix-for-org-fold)
+(define-advice outline-toggle-children (:around (oldfun &rest extra)
fix-for-org-fold)
"Run `org-fold-hide-sublevels' when in org-mode."
(if (derived-mode-p 'org-mode)
(save-excursion
@@ -1520,7 +1530,9 @@ key."
(org-fold-hide-subtree)
(org-fold-show-children)
(org-fold-show-entry 'hide-drawers)))
- (funcall oldfun)))
+ ;; Apply EXTRA to avoid breakages if adviced function definition
+ ;; changes.
+ (apply oldfun extra)))
;; TODO: outline-headers-as-kill