Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix markdown-cycle issue #76

Merged
merged 1 commit into from
Jan 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1985,10 +1985,6 @@ in XEmacs 21."
(if (fboundp 'outline-hide-body)
'outline-hide-body
'hide-body))
(defalias 'markdown-show-entry
(if (fboundp 'outline-show-entry)
'outline-show-entry
'show-entry))
(defalias 'markdown-show-children
(if (fboundp 'outline-show-children)
'outline-show-children
Expand Down Expand Up @@ -4916,6 +4912,27 @@ 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-show-entry ()
(save-excursion
(outline-back-to-heading t)
(outline-flag-region (1- (point))
(progn
(markdown-next-preface)
(if (= 1 (- (point-max) (point)))
(point-max)
(point)))
nil)))

(defun markdown-cycle (&optional arg)
"Visibility cycling for Markdown mode.
If ARG is t, perform global visibility cycling. If the point is
Expand Down