shanecelis / hideshow-org

Provides org-mode like hide and show for hideshow.el
GNU General Public License v2.0
75 stars 9 forks source link

"Hiding only when mark not active" broken when transient-mark-mode is nil #6

Open rfl4kx opened 10 years ago

rfl4kx commented 10 years ago

AFAICS, when transient-mark-mode is nil, the mark remains always active after first activation in a buffer, so the condition in hs-org/hideshow to call hs-toggle-hiding should be updated to

(when (and (equal last-point (point))
           (not (and transient-mark-mode mark-active)))

BTW, a user-defined predicate hook would be useful, as for example I need to disable hideshow-org when on a comment, as it doesn't play well with outshine, e.g.:

(when (and (equal last-point (point))
           (not (and transient-mark-mode mark-active))
           (hs-org-user-predicate))

Thanks for your minor-mode.

dpercy commented 5 years ago

It looks like the standard way to handle this is to call (use-region-p):

Return t if the region is active and it is appropriate to act on it. This is used by commands that act specially on the region under Transient Mark mode.

The return value is t if Transient Mark mode is enabled and the mark is active; furthermore, if ‘use-empty-active-region’ is nil, the region must not be empty. Otherwise, the return value is nil.

For some commands, it may be appropriate to ignore the value of ‘use-empty-active-region’; in that case, use ‘region-active-p’.