all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: how to make next-error work on non-grep non-compilation
Date: Fri, 20 May 2011 13:20:24 -0300	[thread overview]
Message-ID: <jwv62p5uz35.fsf-monnier+gnu.emacs.help@gnu.org> (raw)
In-Reply-To: dc95301b-6ae8-4b3d-8d92-e024d70c9e01@glegroupsg2000goo.googlegroups.com

> (defun skill-vlint-present (file-name)
>   (let (size
>         (vlint (get-buffer-create "vlint")))
>     (with-current-buffer vlint
>       (let ((inhibit-read-only t))
>         (erase-buffer)
>         (insert-file-contents-literally file-name)
>         (when (setq size (- (point-max) (point-min)))
>           (grep-mode))))
>     (when (plusp size)
>       (switch-to-buffer-other-window vlint))))

Looks much better than the code you sent before.  Note that 0 when
interpreted as a boolean in Elisp is the same as true, so the
"(when (setq size (- (point-max) (point-min)))" will always call the
`grep-mode'.  And you can use (buffer-size) instead of (- (point-max)
(point-min)).  Oh, and I'd use (unless (zerop size)...) since `plusp' is
not standard Elisp but only provided by the CL library.


        Stefan


  reply	other threads:[~2011-05-20 16:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 11:41 how to make next-error work on non-grep non-compilation jimka
2011-05-20 11:47 ` Jim Newton
2011-05-20 12:53 ` Stefan Monnier
2011-05-20 13:48   ` Jim Newton
2011-05-20 14:11     ` Stefan Monnier
2011-05-20 14:18       ` Jim Newton
2011-05-20 14:06   ` Jim Newton
2011-05-20 14:54     ` Jim Newton
2011-05-20 16:20       ` Stefan Monnier [this message]
2011-05-20 15:39 ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv62p5uz35.fsf-monnier+gnu.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.