From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Quit and Close Emacs Special Windows Date: Mon, 29 Jun 2020 12:13:41 -0400 Message-ID: <4A9D5E27-D090-4F1B-88DA-34A30ADE54F7@gmail.com> References: <87ftaej5pp.fsf.ref@ergus.i-did-not-set--mail-host-address--so-tickle-me> <87ftaej5pp.fsf@ergus.i-did-not-set--mail-host-address--so-tickle-me> <3c578050-2a23-411e-bad0-c26a7c7ed5ee@default> Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="86669"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Ergus , emacs-devel@gnu.org To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jun 29 18:14:41 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jpwQb-000MRz-A2 for ged-emacs-devel@m.gmane-mx.org; Mon, 29 Jun 2020 18:14:41 +0200 Original-Received: from localhost ([::1]:57208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpwQa-00008B-CR for ged-emacs-devel@m.gmane-mx.org; Mon, 29 Jun 2020 12:14:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpwPk-0007ke-3w for emacs-devel@gnu.org; Mon, 29 Jun 2020 12:13:48 -0400 Original-Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:44684) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jpwPh-0002mn-4L for emacs-devel@gnu.org; Mon, 29 Jun 2020 12:13:47 -0400 Original-Received: by mail-qt1-x834.google.com with SMTP id j10so13224796qtq.11 for ; Mon, 29 Jun 2020 09:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=4OUm1vjjLUKiya1OqPXCOy6iqlqfdWnTrBFsyYZz7aA=; b=J7HZ9e0Sqazh+I+yjcdkITXlx6mOwr+oQGG4ZKSCxK54352LroCnHHFowsvb12yGqZ ALNwwIwKNkGVMuYv8Ra70I3nArI3m9W2FCfJsraYg+pdlz5H3H34fdweLAq9Xqe8stf8 0XlDkNidO+N2kzRJaIvjZ9RILkTUc6iVyugQ86RjApStz2fUeJS3pDDIEX3I4Cm32Agn q7oNb4+yUk3FrdiLrcviwxnb5R1rVA0l1NKfOvNQ6fGfT9aXLvAvPsxOu+jvjsfApw6l 3vjodEWCGVZTYFDFIJRYeTGb0SXSwApqtzGicD2GZGMRfUpnzl1Ql46bdkp47CPHCOLu NOww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=4OUm1vjjLUKiya1OqPXCOy6iqlqfdWnTrBFsyYZz7aA=; b=HtPE/c7+joMuI3gnZT7m/4dD4FaGmYjY85h1j5XDLuLfIFDXIlAvBV/BJeQQEvd24i Gym0HnqaY8jikWZWiIM4SGOV3PJkQJd1banxKHDCbXD1bKTCj50qNQuX6XAP7yNHVXwZ NnWr72RTx5emkAl9pZBGcTUMZSEavXJiT7fER+3C8XINNKayKYIfx5BICndEQvH6Yj/2 zPUA9ox7YaSSsBx1fz4pBDdR/efC4REVcngqvSXBJmido/OBshjmnJb4ST/2N5BVYQ2l Lnxsq2OAASFQkLX3Bx36ijpZjsUDUUo5O6JndFCozJImviZAcJL5f/HW164KAChf7Mrc fX0w== X-Gm-Message-State: AOAM532SmDALznWVIVXiz5YOjZzhkB4yGijevDkaUsS/97m//x0CZ2Yl 6tjzEF/G20DCynihSH6zbFY= X-Google-Smtp-Source: ABdhPJyPT5otMiOCox7Mhtj/95mPebRy7qQiT3n2J67XpdCRQugdcC6hHu+4ej0l6L+h+E5rqUcSQA== X-Received: by 2002:ac8:1654:: with SMTP id x20mr4288935qtk.83.1593447223399; Mon, 29 Jun 2020 09:13:43 -0700 (PDT) Original-Received: from ?IPv6:2601:98a:4200:9210:f1a7:5c4b:7360:abd7? ([2601:98a:4200:9210:f1a7:5c4b:7360:abd7]) by smtp.gmail.com with ESMTPSA id r2sm103481qtn.27.2020.06.29.09.13.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jun 2020 09:13:43 -0700 (PDT) X-Priority: 3 In-Reply-To: <3c578050-2a23-411e-bad0-c26a7c7ed5ee@default> X-Mailer: Apple Mail (2.3608.80.23.2.2) Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=casouri@gmail.com; helo=mail-qt1-x834.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:252568 Archived-At: I use a similar =E2=80=9Csmart=E2=80=9D quit function. When a special = buffer pops up creating a new window, I want that window disappear when = quit; but if the special buffer reused a window, I want Emacs to keep = the window and restore the original buffer. Here is what I use: (defun ghelp-close () "Close ghelp buffer/window." (interactive) (cl-loop for buffer1 in (window-prev-buffers) for buffer =3D (car buffer1) for is-ghelp =3D (eq 'ghelp-page-mode (buffer-local-value 'major-mode buffer)) if (not is-ghelp) do (switch-to-buffer buffer) and return nil finally (delete-window))) Here, instead of looking for special-mode, I look for ghelp-page-mode, = but the idea is the same. I look at the buffer history of the window and = restore previous buffer if I can find one, if not, I delete the window. Yuan=