comparison lisp/code-files.el @ 3950:4cc3828e29bb

[xemacs-hg @ 2007-05-12 13:12:26 by aidan] Have set-buffer-file-coding-system mark the buffer as modified.
author aidan
date Sat, 12 May 2007 13:12:28 +0000
parents a0adf5f08c44
children 579f03038f61
comparison
equal deleted inserted replaced
3949:33b9323388c5 3950:4cc3828e29bb
103 103
104 This overrides the more general specification in 104 This overrides the more general specification in
105 `buffer-file-coding-system-for-read', but is overridden by 105 `buffer-file-coding-system-for-read', but is overridden by
106 `coding-system-for-read'.") 106 `coding-system-for-read'.")
107 107
108 (defun set-buffer-file-coding-system (coding-system &optional force) 108 (defun set-buffer-file-coding-system (coding-system &optional force nomodify)
109 "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM. 109 "Set the file coding-system of the current buffer to CODING-SYSTEM.
110 If optional argument FORCE (interactively, the prefix argument) is not 110 This means that when you save the buffer, it will be converted
111 given, attempt to match the EOL type of the new coding system to 111 according to CODING-SYSTEM. For a list of possible values of CODING-SYSTEM,
112 the current value of `buffer-file-coding-system'." 112 use \\[list-coding-systems].
113 (interactive "zFile coding system: \nP") 113
114 (get-coding-system coding-system) ;; correctness check 114 If CODING-SYSTEM leaves the text conversion unspecified, or if it
115 (if (not force) 115 leaves the end-of-line conversion unspecified, FORCE controls what to
116 (setq coding-system 116 do. If FORCE is nil, get the unspecified aspect (or aspects) from the
117 buffer's previous `buffer-file-coding-system' value (if it is
118 specified there). Otherwise, leave it unspecified.
119
120 This marks the buffer modified so that the succeeding \\[save-buffer]
121 surely saves the buffer with CODING-SYSTEM. From a program, if you
122 don't want to mark the buffer modified, specify t for NOMODIFY.
123 If you know exactly what coding system you want to use,
124 just set the variable `buffer-file-coding-system' directly."
125 (interactive "zCoding system for saving file (default nil): \nP")
126 (check-coding-system coding-system)
127 (if (and coding-system buffer-file-coding-system (null force))
128 (setq coding-system
117 (subsidiary-coding-system 129 (subsidiary-coding-system
118 coding-system 130 coding-system
119 (coding-system-eol-type buffer-file-coding-system)))) 131 (coding-system-eol-type buffer-file-coding-system))))
120 (setq buffer-file-coding-system coding-system) 132 (setq buffer-file-coding-system coding-system)
121 (redraw-modeline t)) 133 ;; XEmacs change; remove a call to ucs-set-table-for-input, which we don't
134 ;; have.
135 (unless nomodify
136 (set-buffer-modified-p t))
137 (force-mode-line-update))
122 138
123 (defun toggle-buffer-file-coding-system () 139 (defun toggle-buffer-file-coding-system ()
124 "Set EOL type of buffer-file-coding-system of the current buffer to 140 "Set EOL type of buffer-file-coding-system of the current buffer to
125 something other than what it is at the moment." 141 something other than what it is at the moment."
126 (interactive) 142 (interactive)
454 (if (local-variable-p 'buffer-file-coding-system (current-buffer)) 470 (if (local-variable-p 'buffer-file-coding-system (current-buffer))
455 ;; if buffer-file-coding-system is already local, just 471 ;; if buffer-file-coding-system is already local, just
456 ;; set its eol type to what was found, if it wasn't 472 ;; set its eol type to what was found, if it wasn't
457 ;; set already. 473 ;; set already.
458 (set-buffer-file-coding-system 474 (set-buffer-file-coding-system
459 (subsidiary-coding-system buffer-file-coding-system 475 (subsidiary-coding-system
460 (coding-system-eol-type coding-system)) t) 476 buffer-file-coding-system
477 (coding-system-eol-type coding-system)) t t)
461 ;; otherwise actually set buffer-file-coding-system. 478 ;; otherwise actually set buffer-file-coding-system.
462 (set-buffer-file-coding-system coding-system t))) 479 (set-buffer-file-coding-system coding-system t t)))
463 ;; ... and `buffer-file-coding-system-when-loaded'. the machinations 480 ;; ... and `buffer-file-coding-system-when-loaded'. the machinations
464 ;; of set-buffer-file-coding-system cause the actual coding system 481 ;; of set-buffer-file-coding-system cause the actual coding system
465 ;; object to be stored, so do that here, too. 482 ;; object to be stored, so do that here, too.
466 (setq buffer-file-coding-system-when-loaded 483 (setq buffer-file-coding-system-when-loaded
467 (get-coding-system coding-system)) 484 (get-coding-system coding-system))