org-exp.el: cosmetic change to `org-get-file-contents'

This commit is contained in:
Bastien Guerry 2011-01-18 01:24:12 +01:00
parent 7b399fe128
commit c8ec337d68
1 changed files with 11 additions and 12 deletions

View File

@ -2182,24 +2182,23 @@ TYPE must be a string, any of:
If PREFIX is a string, prepend it to each line. If PREFIX1 If PREFIX is a string, prepend it to each line. If PREFIX1
is a string, prepend it to the first line instead of PREFIX. is a string, prepend it to the first line instead of PREFIX.
If MARKUP, don't protect org-like lines, the exporter will If MARKUP, don't protect org-like lines, the exporter will
take care of the block they are in. If LINES is a string, take care of the block they are in. If LINES is a string
include only the lines specified." specifying a range of lines, include only those lines ."
(if (stringp markup) (setq markup (downcase markup))) (if (stringp markup) (setq markup (downcase markup)))
(with-temp-buffer (with-temp-buffer
(insert-file-contents file) (insert-file-contents file)
(when lines (when lines
(let (beg end) (let* ((lines (split-string lines "-"))
(setq lines (split-string lines "-") (lbeg (string-to-number (car lines)))
beg (if (string= "" (car lines)) (lend (string-to-number (cadr lines)))
(point-min) (beg (if (zerop lbeg) (point-min)
(goto-char (point-min)) (goto-char (point-min))
(forward-line (1- (string-to-number (car lines)))) (forward-line (1- lbeg))
(point))
end (if (string= "" (cadr lines))
(point-max)
(goto-char (point-min))
(forward-line (1- (string-to-number (cadr lines))))
(point))) (point)))
(end (if (zerop lend) (point-max)
(goto-char (point-min))
(forward-line (1- lend))
(point))))
(narrow-to-region beg end))) (narrow-to-region beg end)))
(when (or prefix prefix1) (when (or prefix prefix1)
(goto-char (point-min)) (goto-char (point-min))