comparison lisp/hm--html-menus/hm--html-indentation.el @ 153:25f70ba0133c r20-3b3

Import from CVS: tag r20-3b3
author cvs
date Mon, 13 Aug 2007 09:38:25 +0200
parents 4103f0995bd7
children
comparison
equal deleted inserted replaced
152:4c132ee2d62b 153:25f70ba0133c
148 (goto-char until) 148 (goto-char until)
149 nil)) 149 nil))
150 150
151 (defun hm--html-is-one-element-tag-p (tag-name) 151 (defun hm--html-is-one-element-tag-p (tag-name)
152 "Returns t, if the tag with the tag-name is a one element tag." 152 "Returns t, if the tag with the tag-name is a one element tag."
153 (assoc :hm--html-one-element-tag 153 (assoc ':hm--html-one-element-tag
154 (cdr (assoc* (downcase tag-name) 154 (cdr (assoc* (downcase tag-name)
155 hm--html-tag-name-alist 155 hm--html-tag-name-alist
156 :test 'string=)))) 156 :test 'string=))))
157 157
158 (defun hm--html-calculate-indent-according-to-previous-tags () 158 (defun hm--html-calculate-indent-according-to-previous-tags ()
222 (skip-chars-backward " \t\n") 222 (skip-chars-backward " \t\n")
223 (hm--html-calculate-indent-according-to-previous-tags)) 223 (hm--html-calculate-indent-according-to-previous-tags))
224 (hm--html-previous-line-indentation))) 224 (hm--html-previous-line-indentation)))
225 )))) 225 ))))
226 226
227
228 ;;; Indentation commands
229
227 (defun hm--html-indent-line () 230 (defun hm--html-indent-line ()
228 "Indent the current line line." 231 "Indent the current line line."
229 (interactive) 232 (interactive)
230 (unless hm--html-disable-indentation 233 (unless hm--html-disable-indentation
231 (indent-line-to (max 0 (hm--html-calculate-indent))))) 234 (let ((pos (- (point-max) (point))))
232 235 (indent-line-to (max 0 (hm--html-calculate-indent)))
233 ;;; Indentation 236 (when (> (- (point-max) pos) (point))
237 (goto-char (- (point-max) pos))))))
238
239 ;(defun hm--html-indent-region (begin end)
240 ; "Indents the region between BEGIN and END according to the major mode."
241 ; (interactive "d\nm")
242 ; (when (< end begin)
243 ; (let ((a end))
244 ; (setq end begin)
245 ; (setq begin a)))
246 ; (save-excursion
247 ; (goto-char begin)
248 ; (let ((old-point))
249 ; (while (and (<= (point) end)
250 ; (not (eq (point) old-point)))
251 ; (setq old-point (point))
252 ; (indent-according-to-mode)
253 ; (forward-line)
254 ; ))))
234 255
235 (defun hm--html-indent-region (begin end) 256 (defun hm--html-indent-region (begin end)
236 "Indents the region between BEGIN and END according to the major mode." 257 "Indents the region between BEGIN and END according to the major mode."
237 (interactive "d\nm") 258 (interactive "d\nm")
238 (when (< end begin) 259 (when (< end begin)
239 (let ((a end)) 260 (let ((a end))
240 (setq end begin) 261 (setq end begin)
241 (setq begin a))) 262 (setq begin a)))
242 (save-excursion 263 (let ((lines (count-lines begin end)))
243 (goto-char begin) 264 (save-excursion
244 (let ((old-point)) 265 (goto-char begin)
245 (while (and (<= (point) end) 266 (loop repeat lines
246 (not (eq (point) old-point))) 267 do (indent-according-to-mode)
247 (setq old-point (point)) 268 (forward-line))))
248 (indent-according-to-mode) 269 )
249 (forward-line)
250 ))))
251
252 270
253 (provide 'hm--html-indentation) 271 (provide 'hm--html-indentation)