Created
January 12, 2016 10:15
-
-
Save syohex/4060513d8bd7601c6afc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 879cf7c508b457cf508bcf50b293e3656b1e7bff | |
Author: Syohei YOSHIDA <syohex@gmail.com> | |
Date: Tue Jan 12 19:12:26 2016 +0900 | |
Fix markdown-cycle issue | |
diff --git a/markdown-mode.el b/markdown-mode.el | |
index e59c4c2..6fbd7ae 100644 | |
--- a/markdown-mode.el | |
+++ b/markdown-mode.el | |
@@ -4916,6 +4916,16 @@ For example, headings inside preformatted code blocks may match | |
(defvar markdown-cycle-global-status 1) | |
(defvar markdown-cycle-subtree-status nil) | |
+(defun markdown-next-preface () | |
+ (let (finish) | |
+ (while (and (not finish) (re-search-forward (concat "\n\\(?:" outline-regexp "\\)") | |
+ nil 'move)) | |
+ (unless (markdown-code-block-at-point) | |
+ (goto-char (match-beginning 0)) | |
+ (setq finish t)))) | |
+ (when (and (bolp) (or outline-blank-line (eobp)) (not (bobp))) | |
+ (forward-char -1))) | |
+ | |
(defun markdown-cycle (&optional arg) | |
"Visibility cycling for Markdown mode. | |
If ARG is t, perform global visibility cycling. If the point is | |
@@ -4973,7 +4983,8 @@ Derived from `org-cycle'." | |
(setq markdown-cycle-subtree-status nil)) | |
((>= eol eos) | |
;; Entire subtree is hidden in one line: open it | |
- (markdown-show-entry) | |
+ (cl-letf (((symbol-function 'outline-next-preface) #'markdown-next-preface)) | |
+ (markdown-show-entry)) | |
(markdown-show-children) | |
(message "CHILDREN") | |
(setq markdown-cycle-subtree-status 'children)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment