diff --git a/ChangeLog b/ChangeLog index a7ec6e4..6bb9968 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,36 @@ * Makefile (dist, debprepare): Use git instead of tla. + * contrib/httpd.el (httpd-send-file): Use insert-file-contents. + + * examples/mwolson/muse-init.el (my-muse-prepare-entry-for-xanga): + Use muse-insert-file-contents. + + * experimental/muse-split.el (muse-publish-file) + (muse-publish-presplit-publish, muse-publish-no-split-function) + (muse-journal-split-by-entry, muse-journal-split-by-month): Use + muse-insert-file-contents. + + * lisp/muse-book.el (muse-book-publish-chapter) + (muse-book-get-directives): Use muse-insert-file-contents. + + * lisp/muse-http.el (muse-http-render-page): Use + muse-insert-file-contents. + + * lisp/muse-poem.el (muse-poem-markup-tag): Use + muse-insert-file-contents. + + * lisp/muse-publish.el (muse-insert-file-or-string) + (muse-publish-file, muse-publish-include-tag) + (muse-published-contents): Use muse-insert-file-contents. + + * lisp/muse.el (muse-insert-file-contents): New function that + inserts a file with character code conversion, but none of the + other frivolities. Since insert-file-contents-literally does not + do character code conversion, it is not suitable for us. + (muse-with-temp-buffer): Mention muse-insert-file-contents rather + than insert-file-contents-literally. + 2007-08-09 Michael Olson * lisp/muse.el (muse-write-file): Pay attention to diff --git a/contrib/httpd.el b/contrib/httpd.el index 747d438..083dcb6 100644 --- a/contrib/httpd.el +++ b/contrib/httpd.el @@ -153,7 +153,7 @@ content.") (defun httpd-send-file (filename) (with-temp-buffer - (insert-file-contents-literally filename) + (insert-file-contents filename) (httpd-send-data (buffer-string)))) (defun httpd-lose (code msg) diff --git a/examples/mwolson/muse-init.el b/examples/mwolson/muse-init.el index 5602e90..ee65413 100644 --- a/examples/mwolson/muse-init.el +++ b/examples/mwolson/muse-init.el @@ -205,7 +205,7 @@ If FILE is not specified, use the published version of the current file." (cddr (muse-project-of-file)))))))) (save-match-data (muse-with-temp-buffer - (insert-file-contents-literally file) + (muse-insert-file-contents file) ;; surround first line in

(goto-char (point-min)) (insert "

") diff --git a/experimental/muse-split.el b/experimental/muse-split.el index 95c79ae..7933358 100644 --- a/experimental/muse-split.el +++ b/experimental/muse-split.el @@ -105,7 +105,7 @@ the file is published no matter what." (muse-publish-presplit-publish file) ;; start a temp buffer for main data (muse-with-temp-buffer - (insert-file-contents-literally file) + (muse-insert-file-contents file) (let ((mainbuffer (current-buffer)) (subcontents)) (mapc @@ -130,7 +130,7 @@ the file is published no matter what." (defun muse-publish-presplit-publish(file) (muse-with-temp-buffer - (insert-file-contents-literally file) + (muse-insert-file-contents file) (let ((muse-publish-markup-regexps muse-publish-presplit-markup-regexps) (muse-publish-markup-functions muse-publish-presplit-functions) (muse-publishing-styles) @@ -203,7 +203,7 @@ Changing this will cause bad things to happen. ") (defun muse-publish-no-split-function (file) (muse-with-temp-buffer - (insert-file-contents-literally file) + (muse-insert-file-contents file) (list `(,(file-name-sans-extension file) . (1 ,(point-max)))))) (defun muse-publish-split-file (file) @@ -342,7 +342,7 @@ the anchor will be output" (defun muse-journal-split-by-entry (file) "Split a muse journal file into days" (muse-with-temp-buffer - (insert-file-contents-literally file) + (muse-insert-file-contents file) (let* ((split-alist) (root-name (file-name-sans-extension file)) (split-regexp "^\\* \\([0-9]\\{8\\}\\)") @@ -383,7 +383,7 @@ the anchor will be output" This function makes the assumption that the entries are sorted. If it isn't then it some of the entries will appear not to be published." (muse-with-temp-buffer - (insert-file-contents-literally file) + (muse-insert-file-contents file) (let* ((split-alist) (root-name (file-name-sans-extension file)) (split-regexp (concat "^\\* \\([0-9]\\{4\\}\\)\\([0-9]\\{2\\}\\)" diff --git a/lisp/muse-book.el b/lisp/muse-book.el index 5935087..6d8c916 100644 --- a/lisp/muse-book.el +++ b/lisp/muse-book.el @@ -90,7 +90,7 @@ but treating the page as if it were a single chapter within a book." (let ((muse-publishing-directives (list (cons "title" title))) (muse-publishing-current-file (cdr entry)) (beg (point)) end) - (insert-file-contents-literally (cdr entry)) + (muse-insert-file-contents (cdr entry)) (setq end (copy-marker (point-max) t)) (muse-publish-markup-region beg end (car entry) style) (goto-char beg) @@ -136,7 +136,7 @@ used for publishing." (narrow-to-region (point) (point)) (unwind-protect (progn - (insert-file-contents-literally file) + (muse-insert-file-contents file) (muse-publish-markup "attributes" `(;; Remove leading and trailing whitespace from the file diff --git a/lisp/muse-http.el b/lisp/muse-http.el index 7a82124..56956ca 100644 --- a/lisp/muse-http.el +++ b/lisp/muse-http.el @@ -153,7 +153,7 @@ cached in memory to speed up serving time." (setq muse-buffer-mtime modified-time)) (goto-char (point-max)) (when (bobp) - (insert-file-contents-literally file t) + (muse-insert-file-contents file t) (let ((styles (cddr (muse-project muse-http-serving-p))) style) (while (and styles (null style)) diff --git a/lisp/muse-poem.el b/lisp/muse-poem.el index 1060e3e..b448de9 100644 --- a/lisp/muse-poem.el +++ b/lisp/muse-poem.el @@ -205,7 +205,7 @@ The form of usage is: (setq beg (point)) (insert (muse-with-temp-buffer - (insert-file-contents-literally page) + (muse-insert-file-contents page) (goto-char (point-min)) (if (assoc "nohead" attrs) (progn diff --git a/lisp/muse-publish.el b/lisp/muse-publish.el index aaa8325..a46a52f 100644 --- a/lisp/muse-publish.el +++ b/lisp/muse-publish.el @@ -546,7 +546,7 @@ to the text with ARGS as parameters." (not (string-match "\n" file-or-string)) (file-readable-p file-or-string)) (setq end (+ beg - (cadr (insert-file-contents-literally file-or-string)))) + (cadr (muse-insert-file-contents file-or-string)))) (insert file-or-string) (setq end (point))) (save-restriction @@ -784,7 +784,7 @@ the file is published no matter what." muse-publish-report-threshhold)) (message "Publishing %s ..." file)) (muse-with-temp-buffer - (insert-file-contents-literally file) + (muse-insert-file-contents file) (muse-publish-markup-buffer (muse-page-name file) style) (when (muse-write-file output-path) (muse-style-run-hooks :final style file output-path target))) @@ -1989,7 +1989,7 @@ explanation of how it works." (file-name-directory muse-publishing-current-file))) (error "No file attribute specified in tag")) (muse-publish-markup-attribute beg end attrs t - (insert-file-contents-literally filename)))) + (muse-insert-file-contents filename)))) (defun muse-publish-mark-up-tag (beg end attrs) "Run an Emacs Lisp function on the region delimted by this tag. @@ -2064,7 +2064,7 @@ The text is removed regardless of whether and part of it is uppercase." (defun muse-published-contents (file) (when (file-readable-p file) (muse-with-temp-buffer - (insert-file-contents-literally file) + (muse-insert-file-contents file) (muse-published-buffer-contents (current-buffer))))) (defun muse-publish-transform-output diff --git a/lisp/muse.el b/lisp/muse.el index 9ba2420..ec590a3 100644 --- a/lisp/muse.el +++ b/lisp/muse.el @@ -258,7 +258,7 @@ See also `with-temp-file' and `with-output-to-string'. Unlike `with-temp-buffer', this will never attempt to save the temp buffer. It is meant to be used along with -`insert-file-contents' or `insert-file-contents-literally'. +`insert-file-contents' or `muse-insert-file-contents'. Additionally, if `debug-on-error' is set to t, keep the buffer around for debugging purposes rather than removing it." @@ -291,6 +291,33 @@ around for debugging purposes rather than removing it." (put 'muse-with-temp-buffer 'lisp-indent-function 0) (put 'muse-with-temp-buffer 'edebug-form-spec '(body)) +(defun muse-insert-file-contents (filename &optional visit) + "Insert the contents of file FILENAME after point. +Do character code conversion, but none of the other unnecessary +things like format decoding or `find-file-hook'. + +If VISIT is non-nil, the buffer's visited filename +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." + (let ((format-alist nil) + (after-insert-file-functions nil) + (find-buffer-file-type-function + (if (fboundp 'find-buffer-file-type) + (symbol-function 'find-buffer-file-type) + nil)) + (inhibit-file-name-handlers + (append '(jka-compr-handler image-file-handler) + inhibit-file-name-handlers)) + (inhibit-file-name-operation 'insert-file-contents)) + (unwind-protect + (progn + (fset 'find-buffer-file-type (lambda (filename) t)) + (insert-file-contents filename visit)) + (if find-buffer-file-type-function + (fset 'find-buffer-file-type find-buffer-file-type-function) + (fmakunbound 'find-buffer-file-type))))) + (defun muse-write-file (filename) "Write current buffer into file FILENAME. Unlike `write-file', this does not visit the file, try to back it