elisp - marked region does not highlight in emacs after changing the buffer -


i'm creating custom .emacs file (using gnu emacs 24.3.1) , in have custom function, bound custom shortcut, copies selected region "(kill-ring-save (region-beginning) (region-end))" pastes in different location. try select new region. when do, region no longer highlighted. mark set, because can copy/paste.

if skip paste step in function, new region highlighted. it's editing buffer in way causes region highlighting stop working.

from https://www.fnal.gov/docs/products/emacs/emacs/emacs_12.html : "any change buffer, such inserting or deleting character, deactivates mark. means subsequent command operates on region error , refuse operate. can make region active again typing c-x c-x. "

c-x c-x calls (exchange-point-and-mark), if call (exchange-point-and-mark) in function, highlighting still not turn on again. why not?

disclaimer: not familiar emacs, i'm trial , erroring working code, can't find way highlight selected region after edit buffer. workaround call different function in .emacs, bound different shortcut, calls (exchange-point-and-mark) , selected region highlighted.

edit: adding representative code

(defun func1 ()   (interactive)   (set-mark (point))   (forward-char)   (forward-char) ; @ point 2 characters highlighted   (set-mark (point))   (forward-char)   (forward-char) ; @ point 2 different characters highlighted )  (defun func2 ()   (interactive)   (set-mark (point))   (forward-char)   (forward-char) ; @ point 2 characters highlighted   (insert "a")   (set-mark (point))   (forward-char)   (forward-char) ; @ point nothing highlighted because of insert, mark set )  (defun func3 ()   ; if call right after calling func2 region highlighted   (interactive)   (exchange-point-and-mark) )  (global-set-key (kbd "<f5> x") 'func1) (global-set-key (kbd "<f5> c") 'func2) (global-set-key (kbd "<f5> v") 'func3) 

[this re-edit after discussion in comments]

after making sure transient-mark-mode enabled (it hilighting) there may not else can done make work.

my speculation transient-mark-mode works during idle time between key inputs , perhaps testing whether buffer modified since last time ran or not, in case function both attempts set , activate mark such hilighting displayed, while @ same time modifying buffer, never succeed in triggering transient-mark-mode hilight anything.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -