Hi

I'm lagging behind the list... I recently saw the new duplicate-line function and I feel I have an alternative, which also takes the region into account:

;;
;; Duplicate region
;;
(defun duplicate-region-after (beg end add-cr)
  "Insert a newline and duplicate after selection"
    (let ((dupstr (buffer-substring-no-properties beg end)))
      (goto-char end)
      (when add-cr (insert "\n"))
      (insert dupstr)))

(defun duplicate-line-or-region (arg)
  "Duplicate the region or the line when nothing is selected"
  (interactive "p")
  (save-excursion
    (let ((b (if mark-active (region-beginning)
           (line-beginning-position)))
        (e (if mark-active (region-end)
           (line-end-position)))
        _ign)
      (dotimes (_ign arg)
        (duplicate-region-after b e (not mark-active)))
      )))

When and if I have CPU cycles I'd like to expand this to take a rectangular region into account.

Best, /PA
--
Fragen sind nicht da um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

Headaches with a Juju log:
unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet