From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ernest =?iso-8859-1?Q?Adrogu=E9?= Newsgroups: gmane.emacs.help Subject: spell-check buffer in background, display buffer only if user interaction is needed Date: Sat, 24 Dec 2016 13:16:51 +0100 Message-ID: <20161224121651.xiodwfbe6akbvey7@doriath.local> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1482581856 19448 195.159.176.226 (24 Dec 2016 12:17:36 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 24 Dec 2016 12:17:36 +0000 (UTC) User-Agent: NeoMutt/20161126 (1.7.1) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 24 13:17:32 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cKlGR-0003Ok-ID for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Dec 2016 13:17:27 +0100 Original-Received: from localhost ([::1]:43237 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKlGS-0008NW-Hc for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Dec 2016 07:17:28 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cKlFz-0008NM-Px for help-gnu-emacs@gnu.org; Sat, 24 Dec 2016 07:17:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cKlFu-0005ob-UN for help-gnu-emacs@gnu.org; Sat, 24 Dec 2016 07:16:59 -0500 Original-Received: from mail-wj0-x242.google.com ([2a00:1450:400c:c01::242]:33683) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cKlFu-0005o7-NP for help-gnu-emacs@gnu.org; Sat, 24 Dec 2016 07:16:54 -0500 Original-Received: by mail-wj0-x242.google.com with SMTP id kp2so43453381wjc.0 for ; Sat, 24 Dec 2016 04:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=2R/IY48rJpX1rJUWu3Vjr10it68ln9g28YUVOJXKryU=; b=EWmKcAzeyKhp7UVfgYDLri2CS2PUHo7GKNigNJoGGGf2d/Bj6Q7s0Xd5A9BYTFIINs khWrz589Rf1B+3NJjimVut+UCLygEEy4HpZI5DujHQmNPFIHsCt4Ix+yx69PcdFEIsYr aXeaYe5vQDHDczCmkPVOs81ypnDwbykyAKZAqYgymDG6TmpAWOMXmdptKZJmmP2U1RLC 2GJtOc3HU6hmh8VaEPkVBOO1ow8dP8s1j4NyvLrrmCEVsUnpS0kyonyMB/5s/ilQpxxx gYBTWtzbAo9QzwM1bPgxnB9Il5ZSnYv5hG8WVmodMba1ydQllizOxS0FRL+WdXGvG7Mt YTrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :mime-version:content-disposition:user-agent; bh=2R/IY48rJpX1rJUWu3Vjr10it68ln9g28YUVOJXKryU=; b=UsUqB0nVsKfiGI0N0jwdwC/E5CtJtu8wPLewq7854/Ag4+/YVNWhsKz3+zTeXhqHW8 ikFUeR0h+ecasg35TGSMeIBB3wXqrPH23n7qf9Yv7Q03ZsgIwdTLmBm1Y8nMz7G9Cc1A j/ISwQgIwFYmkQ37LFs+FU/IORi1BRaRDJ26I3+l6gyKlzaODGfYxK2BKxitiN55uQ76 itNF988TJ9jPsiD4dvpSU+Szeiu2mPunm9cKr/XX3AzBsD801QI/KirK04ElRtxs9+Qu cDZe/6o+vtgMHszinK7J67Gb7LsHndEips+Tbg7FQxVuLawCUK02EXaZQ6kD2JVpBGki COfA== X-Gm-Message-State: AIkVDXJ2UBE1xHbJjb3tNVGdkGTxwiHuFNY1EwppJl2BYS7LfSHcQdyGNmFmmli6IM1ECw== X-Received: by 10.194.247.34 with SMTP id yb2mr16354069wjc.226.1482581813285; Sat, 24 Dec 2016 04:16:53 -0800 (PST) Original-Received: from doriath (203.98.15.37.dynamic.jazztel.es. [37.15.98.203]) by smtp.gmail.com with ESMTPSA id ia7sm44993002wjb.23.2016.12.24.04.16.52 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 Dec 2016 04:16:52 -0800 (PST) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c01::242 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:111997 Archived-At: Hello, Suppose that a function creates a temporary buffer for editing parts a file and switches to it. For the purpose of testing, I'm using the following function instead of the real one (defun create-test-buffer-and-go (text) (pop-to-buffer "*test-buffer*") (erase-buffer) (insert text) (goto-char (point-min))) I'm trying to write a function that will spell-check the temporary buffer in the background and will only display the buffer if user interaction is required, that is, if the buffer contains misspelled words and the user has to choose among a list of corrections. One possibility is to use save-window-excursion and add a hook to ispell-update-post-hook which is run by ispell before creating the *Choices* buffer. (defun ispell-test-buffer () (set-buffer "*test-buffer*") (add-hook 'ispell-update-post-hook (lambda () (pop-to-buffer "*test-buffer*")) t t) (ispell-buffer)) So, using an English dictionary (save-window-excursion (create-test-buffer-and-go "hello")) (ispell-test-buffer) shouldn't display the buffer at all, but passing the string "helloz" should, which it does. The problem is the window is not left open, not sure why. In order to fix this the only thing that occurs to me is have the hook function set a flag, and afterwards display the buffer if the flag is set (defun ispell-test-buffer () (let (required-interaction) (set-buffer "*test-buffer*") (add-hook 'ispell-update-post-hook (lambda () (pop-to-buffer "*test-buffer*") (setq required-interaction t)) t t) (ispell-buffer) (when required-interaction (pop-to-buffer "*test-buffer*")))) but I'm not sure that this approach is right, so I'd like to hear suggestions if somebody has any. Cheers.