From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: how to make next-error work on non-grep non-compilation Date: Fri, 20 May 2011 13:20:24 -0300 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1306269230 22201 80.91.229.12 (24 May 2011 20:33:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 24 May 2011 20:33:50 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 24 22:33:46 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QOyIT-0005fw-7L for geh-help-gnu-emacs@m.gmane.org; Tue, 24 May 2011 22:33:45 +0200 Original-Received: from localhost ([::1]:37916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOyIS-000690-O8 for geh-help-gnu-emacs@m.gmane.org; Tue, 24 May 2011 16:33:44 -0400 Original-Path: usenet.stanford.edu!newsfeed.news.ucla.edu!news.snarked.org!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 21 Injection-Info: mx04.eternal-september.org; posting-host="XiIAvY72ZUxKiQYrt+73Dw"; logging-data="7355"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tIwVt7W6qd9qyv+QbYTEH" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:QMiOHrKtc8lbVB6yOHwgGW4jRds= sha1:4qEsh3AJyog7/fiiWoM1lWY5qTY= Original-Xref: usenet.stanford.edu gnu.emacs.help:186878 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81192 Archived-At: > (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