insert vs highlight.

This commit is contained in:
Kazu Yamamoto 2014-03-31 15:44:50 +09:00
parent bfdc884708
commit ea915993fa

View File

@ -35,8 +35,8 @@
(save-excursion (save-excursion
(ghc-goto-module-position) (ghc-goto-module-position)
(if prefix (if prefix
(insert "import qualified " mod " as " prefix "\n") (insert-before-markers "import qualified " mod " as " prefix "\n")
(insert "import " mod " (" (ghc-enclose expr) ")\n"))))))) (insert-before-markers "import " mod " (" (ghc-enclose expr) ")\n")))))))
(defun ghc-completing-read (fmt lst) (defun ghc-completing-read (fmt lst)
(let* ((def (car lst)) (let* ((def (car lst))
@ -48,14 +48,15 @@
(goto-char (point-max)) (goto-char (point-max))
(if (re-search-backward "^import" nil t) (if (re-search-backward "^import" nil t)
(ghc-goto-empty-line) (ghc-goto-empty-line)
(if (re-search-backward "^module" nil t) (if (not (re-search-backward "^module" nil t))
(progn (goto-char (point-min))
(ghc-goto-empty-line) (ghc-goto-empty-line)
(forward-line) (forward-line)
(unless (eolp) (unless (eolp)
(save-excursion ;; save-excursion is not proper due to insert-before-markers.
(insert "\n")))) (let ((beg (point)))
(goto-char (point-min))))) (insert-before-markers "\n")
(goto-char beg))))))
(defun ghc-goto-empty-line () (defun ghc-goto-empty-line ()
(unless (re-search-forward "^$" nil t) (unless (re-search-forward "^$" nil t)