comparison lisp/files.el @ 434:9d177e8d4150 r21-2-25

Import from CVS: tag r21-2-25
author cvs
date Mon, 13 Aug 2007 11:30:53 +0200
parents 3ecd8885ac67
children 84b14dcb0985
comparison
equal deleted inserted replaced
433:892ca416f0fb 434:9d177e8d4150
2211 (format "%s has changed since visited or saved. Save anyway? " 2211 (format "%s has changed since visited or saved. Save anyway? "
2212 (file-name-nondirectory buffer-file-name))) 2212 (file-name-nondirectory buffer-file-name)))
2213 (error "Save not confirmed")) 2213 (error "Save not confirmed"))
2214 (save-restriction 2214 (save-restriction
2215 (widen) 2215 (widen)
2216 (and (> (point-max) 1) 2216
2217 (/= (char-after (1- (point-max))) ?\n) 2217 ;; Add final newline if required. See `require-final-newline'.
2218 (not (and (eq selective-display t) 2218 (when (and (not (eq (char-before (point-max)) ?\n)) ; common case
2219 (= (char-after (1- (point-max))) ?\r))) 2219 (char-before (point-max)) ; empty buffer?
2220 (or (eq require-final-newline t) 2220 (not (and (eq selective-display t)
2221 (and require-final-newline 2221 (eq (char-before (point-max)) ?\r)))
2222 (y-or-n-p 2222 (or (eq require-final-newline t)
2223 (format "Buffer %s does not end in newline. Add one? " 2223 (and require-final-newline
2224 (buffer-name))))) 2224 (y-or-n-p
2225 (save-excursion 2225 (format "Buffer %s does not end in newline. Add one? "
2226 (goto-char (point-max)) 2226 (buffer-name))))))
2227 (insert ?\n))) 2227 (save-excursion
2228 ;; 2228 (goto-char (point-max))
2229 (insert ?\n)))
2230
2229 ;; Run the write-file-hooks until one returns non-null. 2231 ;; Run the write-file-hooks until one returns non-null.
2230 ;; Bind after-save-hook to nil while running the 2232 ;; Bind after-save-hook to nil while running the
2231 ;; write-file-hooks so that if this function is called 2233 ;; write-file-hooks so that if this function is called
2232 ;; recursively (from inside a write-file-hook) the 2234 ;; recursively (from inside a write-file-hook) the
2233 ;; after-hooks will only get run once (from the 2235 ;; after-hooks will only get run once (from the