Skip to content

Commit

Permalink
Fix markdown-cycle issue
Browse files Browse the repository at this point in the history
Use own outline-show-entry implementation. Because outline-show-entry
uses only header regexp. So it misjudges header like statement, like
comment line of Ruby, in code block. This own implementation searches
header and whether there is in code block.
  • Loading branch information
syohex committed Jan 13, 2016
1 parent 0445628 commit 5438665
Showing 1 changed file with 21 additions and 4 deletions.
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

0 comments on commit 5438665

Please sign in to comment.