I have written a small elisp script which should put oneline or multiline comments based on the current buffer's major mode. The source file is here: https://github.com/amirteymuri/Com/blob/master/com.el
insert-comm+ function which should insert the multiline comments however puts the ending multline-comment string not at the end of the marked region, but some characters before it (depending on major-mode the amount of characters change also). Can someone see where the problem is happening?
This is the
(defun insert-comm+ () "Inserts multiliners to a marked region or a line." (interactive) (let* ((comm-list (comm+)) (comm-begin (concat (first comm-list) "\n")) (comm-end (concat "\n" (second comm-list)))) (if (use-region-p) (let ((b (region-beginning)) (e (region-end))) (progn (goto-char b) (insert comm-begin) (goto-char (1+ e)) (insert comm-end))) (progn (insert comm-begin) (insert comm-end) (backward-char (length comm-end))))))