EMACS 24.1. I need Rebind Ctrl-spaceto execute a custom function that:
- go to end of line
- remove trailing spaces if any
- set the sign (as usual Ctrl-space)
This is my code not working:
(define-key global-map [?\C- ] 'my-set-mark-command)
(defun my-set-mark-command()
(interactive)
(end-of-line)
(delete-char (* -1 (skip-chars-backward "\t\s")));;delete trailing spaces
(set-mark-command nil))
When there are no trailing spaces, it works fine: start selecting and highlighting a region. When trailing spaces: it removes trailing spaces, stops at the end of a line, sets a label, but does not highlight an area.
If I delete the last command ( set-mark-command) and I run it manually M-x set-mark-command, it works. Please, can someone help me to make this function work correctly?
source
share