Fix error when region is inactive
This commit is contained in:
parent
e7f90c1b0d
commit
b713fe1efa
18
init.org
18
init.org
|
@ -3885,8 +3885,6 @@ or with ASK, prompt the user for a language."
|
|||
(t nil)))
|
||||
(column (- (point) (point-at-bol)))
|
||||
(indent (make-string column ?\s))
|
||||
(region-start (region-beginning))
|
||||
(region-end (region-end))
|
||||
(start-string (format "#+BEGIN_%s %s%s\n" type
|
||||
(if src-block-p lang "")
|
||||
(if (and src-block-p header-args)
|
||||
|
@ -3895,13 +3893,15 @@ or with ASK, prompt the user for a language."
|
|||
(end-string (format "%s#+END_%s\n" indent type)))
|
||||
;; create a block around a region - preserve position of point
|
||||
(cond ((region-active-p)
|
||||
(save-excursion
|
||||
;; inserting at region-start would make region-end
|
||||
;; invalid, so we insert at the end first
|
||||
(goto-char region-end)
|
||||
(insert end-string "\n")
|
||||
(goto-char region-start)
|
||||
(insert start-string)))
|
||||
(let ((region-start (region-beginning))
|
||||
(region-end (region-end)))
|
||||
(save-excursion
|
||||
;; inserting at region-start would make region-end
|
||||
;; invalid, so we insert at the end first
|
||||
(goto-char region-end)
|
||||
(insert end-string "\n")
|
||||
(goto-char region-start)
|
||||
(insert start-string))))
|
||||
;; new empty block - insert the block syntax and place point
|
||||
;; inside the block
|
||||
(t (insert start-string)
|
||||
|
|
Loading…
Reference in New Issue