Hot answers tagged

5

The url-get-url-at-point function from the url-util (emacs built-in) package should do the job for you. It is used in interactive commands like browse-url-at-point. (require 'url-util) (defun my/kill-url-at-point () "Kill the url at point." (interactive) (kill-new (url-get-url-at-point))) If you need to copy URL from an HTML page while in an emacs ...


5

You basically just want to be calling indent-rigidly on a copy of the region. That will also deal nicely with indent-tabs-mode (which I think you'll find your version does not). I'd suggest using a temporary buffer, and maintaining the original values for indent-tabs-mode and tab-width. Something like this: (defun my-copy-region-unindented (pad beginning ...


3

It is possible that that you're calling kill-region which is bound to C-w. This is what one would consider the cut command in other applications. If the region is not active it will kill from your point to where the last mark was, which could possibly be the beginning of the buffer. The command view-lossage (bound to C-h l or <f1> l) displays the last ...


3

CUA's help on rectangles (and other things) is slightly hidden away. M-x find-library RET cua-base RET Search the commentary for the section on "CUA rectangle support" (Which is not to suggest that library commentaries in general are "hidden" -- they're a crucial aspect of Emacs' documentation which all users should know how to access. It's just that in ...


2

This is not a bug. You can't use emacs commands in term-char-mode, you must toggle to term-line-mode for these commands... But, you can use the terminal commands instead. For example C-w is the terminal backward-kill-word. fortunately, a lot of commands have (almost) the same behavior in terminal and in emacs (C-k, M-c, M-l, M-. ...). Another problem is ...


2

As @wvxvw and @Drew implied in the comments, I too believe that kill-sexp (bound by default to C-M-k) is a more appropriate command to use than kill-whole-line for the use cases in your examples. For your first example, I would either use C-M-k followed by C-k (to delete the empty line), or kill-whole-line (bound to a convenient key if I use it too often)...


2

I'd rather use standard keyboard short-cuts or the customised solution of @Taylor above, but for completenes sake here are two out of the box Emacs ways: append-to-file: Save your buffer (so it's only working for buffers with an underlying file) and select a region, then M-x a-t-f and specifying your-file will ad the region is at the end of your-file. (To ...


2

Use rectangle commands: C-x r M-w Save the text of the region-rectangle as the last killed rectangle (copy-rectangle-as-kill) C-x r y Yank the last killed rectangle with its upper left corner at point (yank-rectangle)


2

I think you're looking for: (setq mark-even-if-inactive nil)


2

This simple function and keybinding to C-c d will ask you for a number and will delete line that number forward (or backward if you will use negative number): (defun kill-line-relative (&optional arg) "Kill relative line." (interactive "n") (save-excursion (forward-visible-line arg) (kill-whole-line))) (global-set-key (kbd "C-c d") 'kill-...


1

To invoke a function, don't quote it: (kill-whole-line), not ('kill-whole-line). You're looking for function use-region-p, so (use-region-p), not region-selected. (There is no predefined variable region-selected.) You need to pass functions the arguments they require. So (kill-region (region-beginning) (region-end). If you want it to be a function then ...


1

If using evil you can move point to the d and type dt. Another way I often do stuff like this in evil is move point to the d and then go in to visual state with v then move point to where I want (usually using ace-jump) and then type x Some advantages of the 2nd way are: You don't have to bother thinking of just the right character to put after the dt of ...


1

Since no one here has come up with an answer that is sufficient for my needs, I've continued with my aforementioned implementation which uses paredit-backward-delete under certain conditions. What I've come up with isn't very pretty (nor very efficient), but it works well enough and seems to keep true to the spirit of paredit from an end-user perspective. ...


1

I don't think there's anything built-in that's more efficient than this: select text kill selection with C-w move to end of buffer with M-> (i.e., end-of-buffer) yank C-y return to where I started with C-u <space> <space> If you do this a lot, you can wrap these operations into a function: (defun my-yank-at-end (beg end) (interactive "r")...


1

This is the way to get a run of text with the same face under point: (defun face-under-point () (interactive) (let ((face (face-at-point t)) (start (point)) (end (point)) msg) (cl-loop while (eql face (or (get-char-property start 'read-face-name) (get-char-property start '...


1

This one is pretty straightforward, M-k does it. It is not listed in the mini-buffer help, and asking for help with C-? does not show more help. It can be found on this link on rectangle editing with cua mode. Interestingly, I can not find those comments on current cua-rect.el code. But it is there: (cua--rect-M/H-key ?k 'cua-cut-rectangle-as-text). As ...


Only top voted, non community-wiki answers of a minimum length are eligible