@@ -1456,69 +1456,58 @@ key."
14561456; ; Folding in outline-mode is not compatible with org-mode folding
14571457; ; anymore. Working around to avoid breakage of external packages
14581458; ; assuming the compatibility.
1459- (defadvice outline-flag-region (around outline-flag-region@fix-for-org-fold ( from to flag) activate )
1459+ (define-advice outline-flag-region (: around (oldfun from to flag) fix-for-org-fold )
14601460 " Run `org-fold-region' when in org-mode."
1461- (if (eq major -mode 'org-mode )
1462- (setq ad-return-value ( org-fold-region (max from (point-min )) (min to (point-max )) flag 'headline ) )
1463- ad-do-it ))
1461+ (if (derived -mode-p 'org-mode )
1462+ (org-fold-region (max from (point-min )) (min to (point-max )) flag 'headline )
1463+ ( apply oldfun from to flag) ))
14641464
1465- (defadvice outline-next-visible-heading (around outline-next-visible-heading@ fix-for-org-fold (arg) activate )
1465+ (define-advice outline-next-visible-heading (: around (oldfun arg) fix-for-org-fold)
14661466 " Run `org-next-visible-heading' when in org-mode."
1467- (interactive " p" )
1468- (if (eq major-mode 'org-mode )
1469- (setq ad-return-value (org-next-visible-heading arg))
1470- ad-do-it))
1467+ (if (derived-mode-p 'org-mode )
1468+ (org-next-visible-heading arg)
1469+ (apply oldfun arg)))
14711470
1472- (defadvice outline-back-to-heading (around outline-back-to-heading@fix-for-org-fold ( &optional invisible-ok) activate )
1471+ (define-advice outline-back-to-heading (: around (oldfun &optional invisible-ok) fix-for-org-fold )
14731472 " Run `org-back-to-heading' when in org-mode."
1474- (if (eq major-mode 'org-mode )
1475- (setq ad-return-value
1476- (progn
1477- (beginning-of-line )
1478- (or (org-at-heading-p (not invisible-ok))
1479- (let (found)
1480- (save-excursion
1481- (while (not found)
1482- (or (re-search-backward (concat " ^\\ (?:" outline-regexp " \\ )" )
1483- nil t )
1484- (signal 'outline-before-first-heading nil ))
1485- (setq found (and (or invisible-ok (not (org-fold-folded-p)))
1486- (point )))))
1487- (goto-char found)
1488- found))))
1489- ad-do-it))
1490-
1491- (defadvice outline-on-heading-p (around outline-on-heading-p@fix-for-org-fold (&optional invisible-ok) activate)
1473+ (if (derived-mode-p 'org-mode )
1474+ (progn
1475+ (beginning-of-line )
1476+ (or (org-at-heading-p (not invisible-ok))
1477+ (let (found)
1478+ (save-excursion
1479+ (while (not found)
1480+ (or (re-search-backward (concat " ^\\ (?:" outline-regexp " \\ )" )
1481+ nil t )
1482+ (signal 'outline-before-first-heading nil ))
1483+ (setq found (and (or invisible-ok (not (org-fold-folded-p)))
1484+ (point )))))
1485+ (goto-char found)
1486+ found)))
1487+ (apply oldfun invisible-ok)))
1488+
1489+ (define-advice outline-on-heading-p (:around (oldfun &optional invisible-ok) fix-for-org-fold)
14921490 " Run `org-at-heading-p' when in org-mode."
1493- (if (eq major -mode 'org-mode )
1494- (setq ad-return-value ( org-at-heading-p (not invisible-ok) ))
1495- ad-do-it ))
1491+ (if (derived -mode-p 'org-mode )
1492+ (org-at-heading-p (not invisible-ok))
1493+ ( apply oldfun invisible-ok) ))
14961494
1497- (defadvice outline-hide-sublevels (around outline-hide-sublevels@ fix-for-org-fold (levels) activate )
1495+ (define-advice outline-hide-sublevels (: around (oldfun levels) fix-for-org-fold)
14981496 " Run `org-fold-hide-sublevels' when in org-mode."
1499- (interactive (list
1500- (cond
1501- (current-prefix-arg (prefix-numeric-value current-prefix-arg))
1502- ((save-excursion (beginning-of-line )
1503- (looking-at outline-regexp))
1504- (funcall outline-level))
1505- (t 1 ))))
1506- (if (eq major-mode 'org-mode )
1507- (setq ad-return-value (org-fold-hide-sublevels levels))
1508- ad-do-it))
1509-
1510- (defadvice outline-toggle-children (around outline-toggle-children@fix-for-org-fold () activate)
1497+ (if (derived-mode-p 'org-mode )
1498+ (org-fold-hide-sublevels levels)
1499+ (apply oldfun levels)))
1500+
1501+ (define-advice outline-toggle-children (:around (oldfun) fix-for-org-fold)
15111502 " Run `org-fold-hide-sublevels' when in org-mode."
1512- (interactive )
1513- (if (eq major-mode 'org-mode )
1514- (setq ad-return-value
1515- (save-excursion
1516- (org-back-to-heading )
1517- (if (not (org-fold-folded-p (line-end-position )))
1518- (org-fold-hide-subtree)
1519- (org-fold-show-children)
1520- (org-fold-show-entry 'hide-drawers ))))
1521- ad-do-it))
1503+ (if (derived-mode-p 'org-mode )
1504+ (save-excursion
1505+ (org-back-to-heading )
1506+ (if (not (org-fold-folded-p (line-end-position )))
1507+ (org-fold-hide-subtree)
1508+ (org-fold-show-children)
1509+ (org-fold-show-entry 'hide-drawers )))
1510+ (apply oldfun)))
15221511
15231512; ; TODO: outline-headers-as-kill
15241513
0 commit comments