Skip to main content
deleted 5 characters in body
Source Link

When I set up aadd this post-command-hook that inserts text into a buffer:

(defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer :local) 

I cannot mark text regions. This appears to be because some of the commands I use in my post-command-hook function internally set the deactivate-mark to t, which causes the (deactivate-mark) function to be run after I run my post-command-hook function.

I have tried multiple different methods of getting at the stack trace to show me how and why the (deactivate-mark) function is called, but no method has given me a stack trace that includes its caller, so it appears that (deactivate-mark) is the top-level function that is being run. This corroborates with the answer to this question, which explains that the deactivate-mark variable can be set to t during a command in order for mark to be deactivate after the command.

Exact steps to reproduce:

  • Run emacs -Q
  • (optional) Press C-SPC to set mark. Move point around. Observe that the region between point and mark is visually highlighted.
  • Enter the above code, and evaluate it.
  • Press C-SPC to set mark. Move point around. Region between point and mark is not highlighted.

Expected behavior: Region between point and mark is visually highlighted, even after evaluating those 2 lines of elisp. Actual behavior: Region between point and mark is not highlighted.


The answer linked says that as a possible fix, (setq deactivate-mark nil) can be placed at the end of your command to prevent mark from being deactivated, as a possible solution. However, some commands such as kill-region intentionally and quite correctly set it to t. If I set (setq deactivate-mark nil) at the end of my command, I interfere with those commands' correctly deactivating mark once they are run.

That answer also says C-h v deactivate-mark says Automatically becomes buffer-local when set regarding the deactivate-mark variable, but when I run C-h v deactivate-mark, that is not mentioned. Has this been changed? I guess I'll need to do a git bisect...

When I set up a post-command-hook that inserts text into a buffer:

(defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer :local) 

I cannot mark text regions. This appears to be because some of the commands I use in my post-command-hook function internally set the deactivate-mark to t, which causes the (deactivate-mark) function to be run after I run my post-command-hook function.

I have tried multiple different methods of getting at the stack trace to show me how and why the (deactivate-mark) function is called, but no method has given me a stack trace that includes its caller, so it appears that (deactivate-mark) is the top-level function that is being run. This corroborates with the answer to this question, which explains that the deactivate-mark variable can be set to t during a command in order for mark to be deactivate after the command.

Exact steps to reproduce:

  • Run emacs -Q
  • (optional) Press C-SPC to set mark. Move point around. Observe that the region between point and mark is visually highlighted.
  • Enter the above code, and evaluate it.
  • Press C-SPC to set mark. Move point around. Region between point and mark is not highlighted.

Expected behavior: Region between point and mark is visually highlighted, even after evaluating those 2 lines of elisp. Actual behavior: Region between point and mark is not highlighted.


The answer linked says that (setq deactivate-mark nil) can be placed at the end of your command to prevent mark from being deactivated, as a possible solution. However, some commands such as kill-region intentionally and quite correctly set it to t. If I set (setq deactivate-mark nil) at the end of my command, I interfere with those commands' correctly deactivating mark once they are run.

That answer also says C-h v deactivate-mark says Automatically becomes buffer-local when set regarding the deactivate-mark variable, but when I run C-h v deactivate-mark, that is not mentioned. Has this been changed? I guess I'll need to do a git bisect...

When I add this post-command-hook:

(defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer :local) 

I cannot mark text regions. This appears to be because some of the commands I use in my post-command-hook function internally set the deactivate-mark to t, which causes the (deactivate-mark) function to be run after I run my post-command-hook function.

I have tried multiple different methods of getting at the stack trace to show me how and why the (deactivate-mark) function is called, but no method has given me a stack trace that includes its caller, so it appears that (deactivate-mark) is the top-level function that is being run. This corroborates with the answer to this question, which explains that the deactivate-mark variable can be set to t during a command in order for mark to be deactivate after the command.

Exact steps to reproduce:

  • Run emacs -Q
  • (optional) Press C-SPC to set mark. Move point around. Observe that the region between point and mark is visually highlighted.
  • Enter the above code, and evaluate it.
  • Press C-SPC to set mark. Move point around. Region between point and mark is not highlighted.

Expected behavior: Region between point and mark is visually highlighted, even after evaluating those 2 lines of elisp. Actual behavior: Region between point and mark is not highlighted.


The answer linked says that as a possible fix, (setq deactivate-mark nil) can be placed at the end of your command to prevent mark from being deactivated. However, some commands such as kill-region intentionally and quite correctly set it to t. If I set (setq deactivate-mark nil) at the end of my command, I interfere with those commands' correctly deactivating mark once they are run.

That answer also says C-h v deactivate-mark says Automatically becomes buffer-local when set regarding the deactivate-mark variable, but when I run C-h v deactivate-mark, that is not mentioned. Has this been changed? I guess I'll need to do a git bisect...

added 822 characters in body
Source Link

When I run this codeset up a post-command-hook that inserts text into a buffer:

(defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer :local) 

I cannot mark text regions. This happens if I insert text into a buffer duringappears to be because some of the commands I use in my post-command-hook (asfunction internally set the previous code does). I am currently looking into why this happens, but if anybody knows and can tell me, that would be great.

It appears that deactivate-mark is called afterto insert-into-at, which causes the (deactivate-buffermark) if mark is activefunction to be run after I run my post-command-hook function. However, 

I have tried multiple different methods of getting at the stack trace so I can determineto show me how and why it is called, including defining the function using edebug(deactivate-defun and pressing d upon entry, and placing an infinite loop inside of it and sending emacs the SIGUSR2mark) function is called, but no method has given me a stack trace that includes its caller. It, so it appears that (deactivate-mark) is the top-level function that is being run. This corroborates with the answer to this question, which explains that the deactivate-mark variable can be set to t during a command in order for mark to be deactivate after the command.

Exact steps to reproduce:

  • Run emacs -Q
  • (optional) Press C-SPC to set mark. Move point around. Observe that the region between point and mark is visually highlighted.
  • Enter the above code, and evaluate it.
  • Press C-SPC to set mark. Move point around. Region between point and mark is not highlighted.

Expected behavior: Region between point and mark is visually highlighted, even after evaluating those 2 lines of elisp. Actual behavior: Region between point and mark is not highlighted.


The answer linked says that (setq deactivate-mark nil) can be placed at the end of your command to prevent mark from being deactivated, as a possible solution. However, some commands such as kill-region intentionally and quite correctly set it to t. If I set (setq deactivate-mark nil) at the end of my command, I interfere with those commands' correctly deactivating mark once they are run.

That answer also says C-h v deactivate-mark says Automatically becomes buffer-local when set regarding the deactivate-mark variable, but when I run C-h v deactivate-mark, that is not mentioned. Has this been changed? I guess I'll need to do a git bisect...

When I run this code:

(defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer :local) 

I cannot mark text regions. This happens if I insert text into a buffer during the post-command-hook (as the previous code does). I am currently looking into why this happens, but if anybody knows and can tell me, that would be great.

It appears that deactivate-mark is called after insert-into-a-buffer if mark is active. However, I have tried multiple different methods of getting at the stack trace so I can determine why it is called, including defining the function using edebug-defun and pressing d upon entry, and placing an infinite loop inside of it and sending emacs the SIGUSR2, but no method has given me a stack trace that includes its caller. It appears that deactivate-mark is the top-level function that is being run.

Exact steps to reproduce:

  • Run emacs -Q
  • (optional) Press C-SPC to set mark. Move point around. Observe that the region between point and mark is visually highlighted.
  • Enter the above code, and evaluate it.
  • Press C-SPC to set mark. Move point around. Region between point and mark is not highlighted.

Expected behavior: Region between point and mark is visually highlighted, even after evaluating those 2 lines of elisp. Actual behavior: Region between point and mark is not highlighted.

When I set up a post-command-hook that inserts text into a buffer:

(defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer :local) 

I cannot mark text regions. This appears to be because some of the commands I use in my post-command-hook function internally set the deactivate-mark to t, which causes the (deactivate-mark) function to be run after I run my post-command-hook function. 

I have tried multiple different methods of getting at the stack trace to show me how and why the (deactivate-mark) function is called, but no method has given me a stack trace that includes its caller, so it appears that (deactivate-mark) is the top-level function that is being run. This corroborates with the answer to this question, which explains that the deactivate-mark variable can be set to t during a command in order for mark to be deactivate after the command.

Exact steps to reproduce:

  • Run emacs -Q
  • (optional) Press C-SPC to set mark. Move point around. Observe that the region between point and mark is visually highlighted.
  • Enter the above code, and evaluate it.
  • Press C-SPC to set mark. Move point around. Region between point and mark is not highlighted.

Expected behavior: Region between point and mark is visually highlighted, even after evaluating those 2 lines of elisp. Actual behavior: Region between point and mark is not highlighted.


The answer linked says that (setq deactivate-mark nil) can be placed at the end of your command to prevent mark from being deactivated, as a possible solution. However, some commands such as kill-region intentionally and quite correctly set it to t. If I set (setq deactivate-mark nil) at the end of my command, I interfere with those commands' correctly deactivating mark once they are run.

That answer also says C-h v deactivate-mark says Automatically becomes buffer-local when set regarding the deactivate-mark variable, but when I run C-h v deactivate-mark, that is not mentioned. Has this been changed? I guess I'll need to do a git bisect...

added 516 characters in body
Source Link

When I run this code:

(defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer :local) 

I cannot mark text regions. This happens if I insert text into a buffer during the post-command-hook (as the previous code does). I am currently looking into why this happens, but if anybody knows and can tell me, that would be great.

It appears that deactivate-mark is called after insert-into-a-buffer if mark is active. However, I have tried multiple different methods of getting at the stack trace so I can determine why it is called, including defining the function using edebug-defun and pressing d upon entry, and placing an infinite loop inside of it and sending emacs the SIGUSR2, but no method has given me a stack trace that includes its caller. It appears that deactivate-mark is the top-level function that is being run.

Exact steps to reproduce:

  • Run emacs -Q
  • (optional) Press C-SPC to set mark. Move point around. Observe that the region between point and mark is visually highlighted.
  • Enter the above code, and evaluate it.
  • Press C-SPC to set mark. Move point around. Region between point and mark is not highlighted.

Expected behavior: Region between point and mark is visually highlighted, even after evaluating those 2 lines of elisp. Actual behavior: Region between point and mark is not highlighted.

When I run this code:

(defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer :local) 

I cannot mark text regions. This happens if I insert text into a buffer during the post-command-hook (as the previous code does). I am currently looking into why this happens, but if anybody knows and can tell me, that would be great.

It appears that deactivate-mark is called after insert-into-a-buffer if mark is active. However, I have tried multiple different methods of getting at the stack trace so I can determine why it is called, including defining the function using edebug-defun and pressing d upon entry, and placing an infinite loop inside of it and sending emacs the SIGUSR2, but no method has given me a stack trace that includes its caller. It appears that deactivate-mark is the top-level function that is being run.

When I run this code:

(defun insert-into-a-buffer () (with-current-buffer (get-buffer-create "some-buffer") (insert "a"))) (add-hook 'post-command-hook 'insert-into-a-buffer :local) 

I cannot mark text regions. This happens if I insert text into a buffer during the post-command-hook (as the previous code does). I am currently looking into why this happens, but if anybody knows and can tell me, that would be great.

It appears that deactivate-mark is called after insert-into-a-buffer if mark is active. However, I have tried multiple different methods of getting at the stack trace so I can determine why it is called, including defining the function using edebug-defun and pressing d upon entry, and placing an infinite loop inside of it and sending emacs the SIGUSR2, but no method has given me a stack trace that includes its caller. It appears that deactivate-mark is the top-level function that is being run.

Exact steps to reproduce:

  • Run emacs -Q
  • (optional) Press C-SPC to set mark. Move point around. Observe that the region between point and mark is visually highlighted.
  • Enter the above code, and evaluate it.
  • Press C-SPC to set mark. Move point around. Region between point and mark is not highlighted.

Expected behavior: Region between point and mark is visually highlighted, even after evaluating those 2 lines of elisp. Actual behavior: Region between point and mark is not highlighted.

added 516 characters in body
Source Link
Loading
Source Link
Loading