Usually a mouse selected region is highlighted and a region set by (set-mark-command) is not highlighted. But I don't know a programmatic way to check it.
Could anyone help?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
I think you have
transient-mark-mode switched off. Without
transient-mark-mode you do not get a highlighted region after setting
mark with C-SPC and successive motion commands.
If the region is not highlighted, it is not active and
(region-active-p) returns nil.
Even if the region is not active
(mark) can give differing positions. That is the situation without
transient-mark-mode when you have set
mark with C-SPC and moved
point away from that position.
use-region-p to neglect empty active regions.
Not 100% sure what you want to check for but if you wish to do something when the mouse has selected a region then here is one way to do it using Emacs advice functionality.
(defun register-mouse-select(&rest args) (message "mouse select")) (advice-add 'mouse-set-region :after #'register-mouse-select) ;;(advice-remove 'mouse-set-region #'register-mouse-select)