#+END_SRC
+* [[http://ergoemacs.org/emacs/emacs_copy_cut_current_line.html][xah-copy-line-or-region]]
+[2017-03-17 Fri 14:07]
+
+#+BEGIN_SRC emacs-lisp :tangle yes
+ (defun xah-copy-line-or-region ()
+ "Copy current line, or text selection.
+ When called repeatedly, append copy subsequent lines.
+ When `universal-argument' is called first, copy whole buffer (respects `narrow-to-region').
+
+ URL `http://ergoemacs.org/emacs/emacs_copy_cut_current_line.html'
+ Version 2016-06-18"
+ (interactive)
+ (let (-p1 -p2)
+ (if current-prefix-arg
+ (setq -p1 (point-min) -p2 (point-max))
+ (if (use-region-p)
+ (setq -p1 (region-beginning) -p2 (region-end))
+ (setq -p1 (line-beginning-position) -p2 (line-end-position))))
+ (if (eq last-command this-command)
+ (progn
+ (progn ; hack. exit if there's no more next line
+ (end-of-line)
+ (forward-char)
+ (backward-char))
+ ;; (push-mark (point) "NOMSG" "ACTIVATE")
+ (kill-append "\n" nil)
+ (kill-append (buffer-substring-no-properties (line-beginning-position) (line-end-position)) nil)
+ (message "Line copy appended"))
+ (progn
+ (kill-ring-save -p1 -p2)
+ (if current-prefix-arg
+ (message "Buffer text copied")
+ (message "Text copied"))))
+ (end-of-line)
+ (forward-char)
+ ))
+
+ (define-key global-map (kbd "M-w") 'xah-copy-line-or-region)
+#+END_SRC
+
* copy buffer file name to kill ring
Sometimes you need the filename of your current buffer on the command