Here's one approach:
(defun isearch-exit-mark-match ()
"Exit isearch and mark the current match."
(define-key isearch-mode-map (kbd "<C-return>") #'isearch-exit-mark-match)
This binds a different key (C-return) to exit the current isearch and also leave the last ...
avy already supports what you want. See avy-dispatch-alist.
However, the default actions are not enough. I have the following function in my config (here it copies a sexp, but you can change it to copy a line):
(defun my-avy-action-copy-and-yank (pt)
"Copy and yank sexp starting on PT."
Then assign a key to the function ...
Actually for org-table-copy-region it isn't necessary to mark the exact column width! Just mark the beginning of the column somewhere in a cell, then the end by going down the required number of rows and do C-c C-x M-w (for M-x o-t-c-r).
Then go to another cell, where you want to add the column and do C-c C-x C-y (for M-x org-table-paste-rectangle).
Hopefully StarBug gave you an answer to your literal question about stuff between newlines.
Your clarification suggests that you are actually looking for org-element-context.
That function gives you the org element at point which can be a source block.
The returned element has properties like its bounds (:begin and :end) and its contents (:value).
Two rules to take into account when solving your problem:
Do not persistently mess up the syntax table if you do not see through all the consequences. It is used for many tasks.
Do not advice forward-word to solve your problem. It is also used for many tasks you do not aprehend at the first look.
But, what you can do is rebinding the keys for forward-char ...
At first, note that pdf-sync binds mouse-double-1 in the minor mode pdf-sync-minor-mode to pdf-sync-backward-search-mouse. So one should probably only bind it in a minor mode that can be deactivated again.
The following code defines a minor mode pdf-sel-mode that binds mouse-double-1 to a new command pdf-sel-mouse. pdf-sel-mouse selects the word below the ...
Library Isearch+ lets you do that easily, and even toggle it on/off on the fly.
Non-nil option isearchp-set-region-flag automatically sets the region (selection) around the last search target when you quit isearch.
Command isearchp-toggle-set-region, bound to M-s M-SPC during isearch toggles option isearchp-set-region-flag.
The two commands org-table-select-col and org-table-copy-col in the following lisp code allow the selection and the copying of the current table column. You can bind it to the key of your liking and/or insert it via easy-menu-define-key into org-tbl-menu.
(defun org-table-goto-col-beginning ()
"Go to beginning of current column and return `point'."
The transient-mark-mode-hook is called when you enter/leave the Transient Mark Mode, which is enabled by default starting from Emacs 23. Only when it's enabled, setting the mark will activate it and highlight the region.
You could try the following code.
,@(let ((m (make-sparse-keymap)))
(define-key m (kbd ...
The following is based on Tobias's answer but use Advising instead:
(define-advice kill-ring-save (:around (old-fun &rest args) highlight)
"Save the text selection and keep the selection highlight."
(apply old-fun args)))
If you need to undo it, use
(advice-remove 'kill-ring-save 'kill-ring-save@highlight)
The function kill-ring-save-keep-selection defined in the following emacs-lisp snippet works like kill-ring-save but keeps the selection. I've bound it to M-W in contrast to M-w for kill-ring-save.
`(defun kill-ring-save-keep-selection (&rest args)
"Just like `kill-ring-save' with arguments ARGS but keep selection."
Use M-| (shell-command-on-region) then sh to pipe the current region to Bash. It works because bash supports running program from STDIN, e.g.,
~ $ echo 'date' | sh
Mon Feb 25 21:54:51 CST 2019
M-| runs via a fresh shell every time, so I'm not sure if it can work in your case.
You need to say that this command is a navigation command, by replacing your
C-h o interactive RET explains that:
If the string begins with ^ and shift-select-mode is non-nil,
Emacs first calls the function handle-shift-selection.
Here is a function that returns the text between two surrounding blank lines:
(defun region-between-surrounding-blank-lines ()
(let ((beg nil) (end nil))
(re-search-backward (rx bol (* blank) eol))
(setq beg (point))
(re-search-forward (rx bol (* blank) eol))
(setq end (- (...
One can easily define a new command that displays a buffer with a given substring in its name.
There are some conceptional things to consider:
It may be that none of the living buffers has the substring in its name. The example code bails out in that case.
There may be multiple buffers with that substring in their name. The example code selects one of ...
Not built in but another package for this is called objed (I'm the author). You can mark any text object with m the point is moved to the next object of current type automatically. Unmark any object by navigating to it and press m again. Here is an example screencast:
Org mode adds the org-date face to the timestamps, so you should be
able to use the following to select the timestamp at point.
(defun your-mark-org-timestamp ()
(when (eq (get-text-property (point) 'face) 'org-date)
(let ((beg (previous-property-change (point) nil (line-beginning-position)))
(end (next-property-change (point)...
The original poster has indicated (in a comment) a desire "to create a highlighted region, so that [he/she] can copy or cut the region (i.e., the timestamp)". The following function returns the timestamp at point without permanently moving point to that location. The user can modify this function to do things like (kill-new ts) to put the timestamp into ...
Please consult the documentation for replace-string (you get the doc with C-h f replace-string RET). The Section on the arguments START and END clearly says how to reproduce the interactive behavior in elisp functions:
Operates on the region between START and END (if both are nil, from point
to the end of the buffer). Interactively, if Transient Mark ...
Posting own answer which mostly works as I'd like (needed some special consideration for evil mode and fci).
While it works well for basic usage, errors will also replace the selection,
ideally a nonzero exit code would display as a message instead of putting the error into the editor.
;; See: https://emacs.stackexchange.com/a/34900/2418
;; Wrapper for '...
You can test whether there is an active selection of text using function region-active-p. C-h f region-active-p tells you:
region-active-p is a compiled Lisp function in simple.el.
Return non-nil if Transient Mark mode is enabled and the mark is active.
Some commands act specially on the region when Transient Mark
cute-jumpers answer is perfectly functional. If you want to bind the action to another key rather than use avy's internal dispatch process then the following adapted code works quite well:
(defun my-avy-paste-word (char)
"Paste a word selected with avy"
(interactive (list (read-char "char:" t)))
(let ((avy-action 'my-copy-word))