emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] highlight region only if it is of non-zero length?


From: Eli Zaretskii
Subject: Re: [RFC] highlight region only if it is of non-zero length?
Date: Wed, 12 Dec 2012 18:30:31 +0200

> Date: Wed, 12 Dec 2012 08:28:08 -0700
> From: Davis Herring <address@hidden>
> CC: Emacs development discussions <address@hidden>,
>         Eli Zaretskii <address@hidden>
> 
> > +  if (!NILP (Vtransient_mark_mode)
> > +      && !NILP (BVAR (current_buffer, mark_active))
> > +      && XMARKER (BVAR (current_buffer, mark))->buffer != NULL
> > +      && (markpos = XMARKER (BVAR (current_buffer, mark))->charpos) != PT)
> > +    /* nothing */;
> > +  else
> > +    markpos = -1;
> 
> Since everything in it is negated anyway, I would De Morgan that:
> 
> +  if (NILP (Vtransient_mark_mode)
> +      || NILP (BVAR (current_buffer, mark_active))
> +      || XMARKER (BVAR (current_buffer, mark))->buffer == NULL
> +      || (markpos = XMARKER (BVAR (current_buffer, mark))->charpos) == PT)
> +    markpos = -1;

IMO, it's better to negate everything, since the original conditions
are for when region is non-empty:

+  if (!(!NILP (Vtransient_mark_mode)
+        && !NILP (BVAR (current_buffer, mark_active))
+        && XMARKER (BVAR (current_buffer, mark))->buffer != NULL
+        && (markpos = XMARKER (BVAR (current_buffer, mark))->charpos) != PT))
+    markpos = -1;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]