Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use muse-insert-file-contents rather than insert-file-contents-literally

2007-08-10  Michael Olson  <mwolson@gnu.org>

	* 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.
  • Loading branch information...
commit 796fba2c8a97aae674dbb4955aa4afda4c3ff41a 1 parent f18db73
@mwolson mwolson authored
View
30 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 <mwolson@gnu.org>
* lisp/muse.el (muse-write-file): Pay attention to
View
2  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)
View
2  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 <h3></h3>
(goto-char (point-min))
(insert "<h3>")
View
10 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\\}\\)"
View
4 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
View
2  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))
View
2  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
View
8 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 <include> 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
View
29 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
Please sign in to comment.
Something went wrong with that request. Please try again.