[Top][All Lists]

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

Re: How to quit?

From: Bob Proulx
Subject: Re: How to quit?
Date: Wed, 25 Feb 2015 11:54:54 -0700
User-agent: Mutt/1.5.23 (2014-03-12)

Marcin Borkowski wrote:
> OK, so I have a problem, and it doesn't show up when I do emacs -Q.  So
> I take a deep breath and bisect my 900-line init.el...
> In LaTeX, however, when I have some weird problem, I can put \endinput
> in a file, and everything past that is ignored.  Is there anything like
> that in Elisp?
> It just occured to me that (debug) /might/ work, and so might
> (keyboard-quit).  Is this a good idea?  Are there any others?

The way I do this myself is to copy the file off to a safe place as a
backup.  Then use two copies of emacs.  In one copy I chop the file up
into the bisections.  The other copy I start and stop repeatedly
letting it load the init file possibly with or without --debug-init to
debug the file.  By using two emacs processes I can keep one open with
the init file being chopped up.  That one I can easily work through
the process like this following.  Note that I disable transient mark
mode and line-move-visual as evil.

  C-x h mark-whole-buffer
  M-= count-words-region
  ...say the buffer has 120 lines...
  C-u 60 C-n
  C-w kill-region
  C-x C-s save-buffer
  ...test...  problem in remaining or removed section?...

If in the remaining section then cut it in half again.  If in the
removed section then undo the region kill and then kill the other half
save and test again.  Continue until you have converged on the
problem.  Once I get things reduced to a single screen I can usually
see the problem by eye and inspection.

Good luck!

P.S.  There are many ways to determine the number of lines in the file
to start the bisection.  There is M-x what-line.  The line number has
been added to the mode line in recent versions so simply jump to the
bottom and look in the modeline.  Other ways.

There are many ways to cut the file in half.  If you don't like moving
by lines or have line-move-visual enabled so that next-line doesn't
actually move by lines then there is M-g g goto-line to jump there
directly.  Also the movement commands M-> and M-< leave the mark
behind.  Use C-x C-x to view the extent of the region between mark and

The M-> end-of-buffer and M-< beginning-of-buffer commands have an odd
additional behavior.

  With numeric arg N, put point N/10 of the way from the beginning.
  If the buffer is narrowed, this command uses the beginning of the
  accessible part of the buffer.

Therefore running M-< C-u 5 M-> will take you to the middle of the

reply via email to

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