unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6902: 23.2; indent-line-to possible devide by zero error bug
@ 2010-08-24 15:27 Arik Mitschang
  2010-08-25 19:32 ` Glenn Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Arik Mitschang @ 2010-08-24 15:27 UTC (permalink / raw)
  To: 6902

In indent.el the indent-line-to function has a comparison that devides
the current column count by tab-width, whose value is an integerp and
allowed to be zero (and in my experience is often 0). I noticed the
issue in specific with org mode which utilizes this function for a lot
of interesting tasks.

I can provide the following patch which makes a check to avoid an
arithmetic error:

=== modified file 'lisp/indent.el'
--- lisp/indent.el	2010-05-19 03:06:48 +0000
+++ lisp/indent.el	2010-08-24 15:20:39 +0000
@@ -177,7 +177,9 @@
   (back-to-indentation)
   (let ((cur-col (current-column)))
     (cond ((< cur-col column)
-	   (if (>= (- column (* (/ cur-col tab-width) tab-width)) tab-width)
+	   (if (and (> tab-width 0)
+		    (>= (- column (* (/ cur-col tab-width) tab-width)) 
+			tab-width))
 	       (delete-region (point)
 			      (progn (skip-chars-backward " ") (point))))
 	   (indent-to column))

Thanks,
~Arik





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#6902: 23.2; indent-line-to possible devide by zero error bug
  2010-08-24 15:27 bug#6902: 23.2; indent-line-to possible devide by zero error bug Arik Mitschang
@ 2010-08-25 19:32 ` Glenn Morris
  2010-08-25 20:04   ` Arik Mitschang
  0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2010-08-25 19:32 UTC (permalink / raw)
  To: Arik Mitschang; +Cc: 6902

Arik Mitschang wrote:

> In indent.el the indent-line-to function has a comparison that devides
> the current column count by tab-width, whose value is an integerp and
> allowed to be zero (and in my experience is often 0).

Why do you want to set tab-width to 0?

A quick grep for tab-width shows other places that will break.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#6902: 23.2; indent-line-to possible devide by zero error bug
  2010-08-25 19:32 ` Glenn Morris
@ 2010-08-25 20:04   ` Arik Mitschang
  2011-04-10 20:56     ` Chong Yidong
  0 siblings, 1 reply; 4+ messages in thread
From: Arik Mitschang @ 2010-08-25 20:04 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 6902

Glenn Morris writes:
 > Arik Mitschang wrote:
 > 
 > > In indent.el the indent-line-to function has a comparison that devides
 > > the current column count by tab-width, whose value is an integerp and
 > > allowed to be zero (and in my experience is often 0).
 > 
 > Why do you want to set tab-width to 0?

Honestly I cannot remember, but I had it set there and I assume there
was a reason.

 > 
 > A quick grep for tab-width shows other places that will break.

The fact that it's value can be zero (without even warning in the doc
string) and this value causes functionality to break doesn't seem good
to me. If nobody but me ever had it set to zero, then perhaps just
updating its doc-string to warn users away from that value would be
nice.

Thanks,
~Arik





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#6902: 23.2; indent-line-to possible devide by zero error bug
  2010-08-25 20:04   ` Arik Mitschang
@ 2011-04-10 20:56     ` Chong Yidong
  0 siblings, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2011-04-10 20:56 UTC (permalink / raw)
  To: Arik Mitschang; +Cc: 6902

Arik Mitschang <arik.mitschang@gmail.com> writes:

>  > A quick grep for tab-width shows other places that will break.
>
> The fact that it's value can be zero (without even warning in the doc
> string) and this value causes functionality to break doesn't seem good
> to me. If nobody but me ever had it set to zero, then perhaps just
> updating its doc-string to warn users away from that value would be
> nice.

I have made such an update to the doc-string.  It doesn't seem
worthwhile to try to handle zero tab-widths in all the places where it
could be problematic.  Thanks.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-10 20:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-24 15:27 bug#6902: 23.2; indent-line-to possible devide by zero error bug Arik Mitschang
2010-08-25 19:32 ` Glenn Morris
2010-08-25 20:04   ` Arik Mitschang
2011-04-10 20:56     ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).