Skip to content

Commit

Permalink
Use muse-insert-file-contents rather than insert-file-contents-literally
Browse files Browse the repository at this point in the history
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
mwolson committed Aug 11, 2007
1 parent f18db73 commit 796fba2
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 16 deletions.
30 changes: 30 additions & 0 deletions ChangeLog
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contrib/httpd.el
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/mwolson/muse-init.el
Expand Up @@ -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>")
Expand Down
10 changes: 5 additions & 5 deletions experimental/muse-split.el
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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\\}\\)")
Expand Down Expand Up @@ -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\\}\\)"
Expand Down
4 changes: 2 additions & 2 deletions lisp/muse-book.el
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lisp/muse-http.el
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion lisp/muse-poem.el
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions lisp/muse-publish.el
Expand Up @@ -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
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
29 changes: 28 additions & 1 deletion lisp/muse.el
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 796fba2

Please sign in to comment.