aboutsummaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-14 04:29:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-14 04:29:35 +0000
commita6c8346da12a013c98b6016304a946eeaa3a723a (patch)
tree44f8994926fb3e49802c52be7b134717fcf384ff /misc
parentcac997eb95eb74a48febb54e357bfe991ad7de6c (diff)
downloadruby-a6c8346da12a013c98b6016304a946eeaa3a723a.tar.gz
rdoc-mode.el: fill indented block
* misc/rdoc-mode.el (rdoc-fill-paragraph): fill indented block by list. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'misc')
-rw-r--r--misc/rdoc-mode.el40
1 files changed, 37 insertions, 3 deletions
diff --git a/misc/rdoc-mode.el b/misc/rdoc-mode.el
index 1bfd34bf2d..c26c2ee564 100644
--- a/misc/rdoc-mode.el
+++ b/misc/rdoc-mode.el
@@ -32,15 +32,49 @@
(run-hooks 'rdoc-mode-hook)
)
-(defun rdoc-fill-paragraph (&rest args)
+(defun rdoc-fill-paragraph (&optional justify region)
"Fills paragraph, except for cited region"
(interactive (progn
(barf-if-buffer-read-only)
(list (if current-prefix-arg 'full))))
(save-excursion
(beginning-of-line)
- (unless (looking-at "^ +")
- (apply 'fill-paragraph args))))
+ (save-restriction
+ (let ((pos (point)) beg end indent hanging)
+ (cond
+ ((looking-at "^ +\\(\\*\\s *\\)")
+ (setq indent (- (match-end 0) (match-beginning 0))
+ hanging (- (match-end 1) (match-beginning 1))))
+ ((looking-at "^ +")
+ (setq indent (- (match-end 0) (match-beginning 0)))
+ (when (and (re-search-backward "^[^ ]\\|^\\( *\\(\\* *\\)\\)" nil t)
+ (match-beginning 1)
+ (= indent (- (match-end 1) (match-beginning 1))))
+ (setq hanging (- (match-end 2) (match-beginning 2)))
+ (setq beg (match-beginning 1))))
+ ((setq beg t)))
+ (when beg
+ (when indent
+ (goto-char pos)
+ (while (progn (beginning-of-line 2)
+ (and (looking-at "^\\( +\\)\\S ")
+ (= indent (- (match-end 1) (match-beginning 1))))))
+ (setq end (point))
+ (when (and beg (not region))
+ (setq region (list beg end))
+ (narrow-to-region beg end)
+ ))
+ (goto-char pos)
+ (fill-paragraph justify region)
+ (when (and indent
+ (or (goto-char beg) t)
+ (or (beginning-of-line 2) t)
+ (looking-at "^\\( +\\)")
+ (= (- indent hanging) (- (match-end 0) (match-beginning 0))))
+ (insert-char ?\s hanging)
+ (beginning-of-line)
+ (narrow-to-region (point) end)
+ (fill-paragraph justify (list (point) end))))))))
(defun rdoc-setup-keys ()
(interactive)