This is basically a rewrite of `mdw-tabify', to make it cleaner, and
respect the variable setting.
-(defun mdw-tabify (s)
- "Tabify the string S. This is a horrid hack."
- (save-excursion
+(defun mdw-maybe-tabify (s)
+ "Tabify or untabify the string S, according to `indent-tabs-mode'."
+ (with-temp-buffer
- (let (start end)
- (beginning-of-line)
- (setq start (point-marker))
+ (let ((tabfun (if indent-tabs-mode #'tabify #'untabify)))
- (setq end (point-marker))
- (tabify start end)
- (setq s (buffer-substring start (1- end)))
- (delete-region start end)
- (set-marker start nil)
- (set-marker end nil)
- s))))
+ (let ((start (point-min)) (end (point-max)))
+ (funcall tabfun start end)
+ (setq s (buffer-substring start (1- end))))))))
(defun mdw-examine-fill-prefixes (l)
"Given a list of dynamic fill prefixes, pick one which matches
(defun mdw-examine-fill-prefixes (l)
"Given a list of dynamic fill prefixes, pick one which matches
at the start of a line, and match data must be saved."
(cond ((not l) nil)
((looking-at (car (car l)))
at the start of a line, and match data must be saved."
(cond ((not l) nil)
((looking-at (car (car l)))
- (mdw-tabify (apply #'concat
- (mapcar #'mdw-do-prefix-match
- (cdr (car l))))))
+ (mdw-maybe-tabify (apply #'concat
+ (mapcar #'mdw-do-prefix-match
+ (cdr (car l))))))
(t (mdw-examine-fill-prefixes (cdr l)))))
(defun mdw-maybe-car (p)
(t (mdw-examine-fill-prefixes (cdr l)))))
(defun mdw-maybe-car (p)