X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fcode-files.el;h=2d5c5eff3c7166f0a26505d8e283146209582b6b;hb=3c2ae053476ec27340f9af5d95cddb7014035bd0;hp=d85434817eebca0ab4fac4f05e0e6764debb6435;hpb=762383636a99307282c2d93d26c35c046ec24da1;p=chise%2Fxemacs-chise.git.1 diff --git a/lisp/code-files.el b/lisp/code-files.el index d854348..2d5c5ef 100644 --- a/lisp/code-files.el +++ b/lisp/code-files.el @@ -17,7 +17,7 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with XEmacs; see the file COPYING. If not, write to the +;; along with XEmacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. @@ -116,7 +116,8 @@ something other than what it is at the moment." (coding-system-base buffer-file-coding-system) (cond ((eq eol-type 'lf) 'crlf) ((eq eol-type 'crlf) 'lf) - ((eq eol-type 'cr) 'lf)))))) + ((eq eol-type 'cr) 'lf)))) + (set-buffer-modified-p t))) (define-obsolete-function-alias 'set-file-coding-system @@ -197,24 +198,23 @@ object (the entry specified a coding system)." ((find-coding-system codesys)) )))) -;; This is completely broken, not only in implementation (does not +;; This was completely broken, not only in implementation (does not ;; understand MIME), but in concept -- such high-level decoding should -;; be done by mail readers, not by IO code! +;; be done by mail readers, not by IO code! Removed 2000-04-18. -;(defun convert-mbox-coding-system (filename visit start end) -;... +;(defun convert-mbox-coding-system (filename visit start end) ...) (defun find-coding-system-magic-cookie () - "Look for the coding-system magic cookie in the current buffer.\n" -"The coding-system magic cookie is the exact string\n" -"\";;;###coding system: \" followed by a valid coding system symbol,\n" -"somewhere within the first 3000 characters of the file. If found,\n" -"the coding system symbol is returned; otherwise nil is returned.\n" -"Note that it is extremely unlikely that such a string would occur\n" -"coincidentally as the result of encoding some characters in a non-ASCII\n" -"charset, and that the spaces make it even less likely since the space\n" -"character is not a valid octet in any ISO 2022 encoding of most non-ASCII\n" -"charsets." + "Look for the coding-system magic cookie in the current buffer. +The coding-system magic cookie is the exact string +\";;;###coding system: \" followed by a valid coding system symbol, +somewhere within the first 3000 characters of the file. If found, +the coding system symbol is returned; otherwise nil is returned. +Note that it is extremely unlikely that such a string would occur +coincidentally as the result of encoding some characters in a non-ASCII +charset, and that the spaces make it even less likely since the space +character is not a valid octet in any ISO 2022 encoding of most non-ASCII +charsets." (save-excursion (goto-char (point-min)) (or (and (looking-at @@ -284,7 +284,7 @@ Return t if file exists." (set-buffer (get-buffer-create " *load*")) (erase-buffer) (let ((coding-system-for-read 'raw-text)) - (insert-file-contents path nil 1 3001)) + (insert-file-contents path nil 0 3000)) (find-coding-system-magic-cookie)) (if elc ;; if reading a byte-compiled file and we didn't find @@ -353,7 +353,7 @@ CODING-SYSTEM (the actual coding system used to decode the file), and a cons of absolute pathname and length of data inserted (the same thing as will be returned from `insert-file-contents').") -(defun insert-file-contents (filename &optional visit beg end replace) +(defun insert-file-contents (filename &optional visit start end replace) "Insert contents of file FILENAME after point. Returns list of absolute file name and length of data inserted. If second argument VISIT is non-nil, the buffer's visited filename @@ -361,9 +361,9 @@ and last save file modtime are set, and it is marked unmodified. If visiting and the file does not exist, visiting is completed before the error is signaled. -The optional third and fourth arguments BEG and END +The optional third and fourth arguments START and END specify what portion of the file to insert. -If VISIT is non-nil, BEG and END must be nil. +If VISIT is non-nil, START and END must be nil. If optional fifth argument REPLACE is non-nil, it means replace the current buffer contents (in the accessible portion) with the file contents. This is better than simply deleting and inserting @@ -416,7 +416,7 @@ and `insert-file-contents-post-hook'." coding-system) (setq coding-system 'undecided))) (setq return-val - (insert-file-contents-internal filename visit beg end + (insert-file-contents-internal filename visit start end replace coding-system ;; store here! 'used-codesys)) @@ -460,20 +460,19 @@ and `insert-file-contents-post-hook'." (defvar write-region-pre-hook nil "A special hook to decide the coding system used for writing out a file. -Before writing a file, `write-region' calls the functions on this hook -with arguments START, END, FILENAME, APPEND, VISIT, and CODING-SYSTEM, -the same as the corresponding arguments in the call to -`write-region'. +Before writing a file, `write-region' calls the functions on this hook with +arguments START, END, FILENAME, APPEND, VISIT, LOCKNAME and CODING-SYSTEM, +the same as the corresponding arguments in the call to `write-region'. -The return value of the functions should be either +The return value of each function should be one of -- nil -- A coding system or a symbol denoting it, indicating the coding system - to be used for reading the file + to be used for writing the file -- A list of two elements (absolute pathname and length of data written), - which is used as the return value to `write-region'. In this - case, `write-region' assumes that the function has written - the file for itself and suppresses further writing. + which is used as the return value to `write-region'. In this case, + `write-region' assumes that the function has written the file and + returns. If any function returns non-nil, the remaining functions are not called.") @@ -481,13 +480,17 @@ If any function returns non-nil, the remaining functions are not called.") "A hook called by `write-region' after a file has been written out. The functions on this hook are called with arguments START, END, -FILENAME, APPEND, VISIT, and CODING-SYSTEM, the same as the +FILENAME, APPEND, VISIT, LOCKNAME, and CODING-SYSTEM, the same as the corresponding arguments in the call to `write-region'.") -(defun write-region (start end filename &optional append visit lockname coding-system) +(defun write-region (start end filename + &optional append visit lockname coding-system) "Write current region into specified file. By default the file's existing contents are replaced by the specified region. -When called from a program, takes three arguments: +Called interactively, prompts for a file name. With a prefix arg, prompts +for a coding system as well. + +When called from a program, takes three required arguments: START, END and FILENAME. START and END are buffer positions. Optional fourth argument APPEND if non-nil means append to existing file contents (if any). @@ -506,19 +509,19 @@ to the file, instead of any buffer contents, and END is ignored. Optional seventh argument CODING-SYSTEM specifies the coding system used to encode the text when it is written out, and defaults to the value of `buffer-file-coding-system' in the current buffer. - Interactively, with a prefix arg, you will be prompted for the - coding system. See also `write-region-pre-hook' and `write-region-post-hook'." (interactive "r\nFWrite region to file: \ni\ni\ni\nZCoding-system: ") (setq coding-system (or coding-system-for-write (run-hook-with-args-until-success - 'write-region-pre-hook start end filename append visit lockname) + 'write-region-pre-hook + start end filename append visit lockname coding-system) coding-system buffer-file-coding-system (find-file-coding-system-for-write-from-filename filename) )) (if (consp coding-system) + ;; One of the `write-region-pre-hook' functions wrote the file coding-system (let ((func (coding-system-property coding-system 'pre-write-conversion))) @@ -551,9 +554,4 @@ See also `write-region-pre-hook' and `write-region-post-hook'." start end filename append visit lockname coding-system))) -;;; The following was all that remained in mule-files.el, so I moved it -;;; here for neatness. -sb -(when (featurep 'mule) - (setq-default buffer-file-coding-system 'iso-2022-8)) - ;;; code-files.el ends here