From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: `emacs -nw', `framep' returning `t', `display-graphic-p' returning `nil' Date: Sun, 17 Dec 2017 19:34:39 +0200 Message-ID: <836095qmvk.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1513531979 15762 195.159.176.226 (17 Dec 2017 17:32:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 17 Dec 2017 17:32:59 +0000 (UTC) Cc: emacs-devel@gnu.org To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 17 18:32:55 2017 Return-path: Envelope-to: ged-emacs-devel@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 1eQco2-0003lQ-Pz for ged-emacs-devel@m.gmane.org; Sun, 17 Dec 2017 18:32:55 +0100 Original-Received: from localhost ([::1]:55008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQcpy-0000af-OA for ged-emacs-devel@m.gmane.org; Sun, 17 Dec 2017 12:34:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQcpl-0000aL-I7 for emacs-devel@gnu.org; Sun, 17 Dec 2017 12:34:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQcpg-0004RR-MV for emacs-devel@gnu.org; Sun, 17 Dec 2017 12:34:41 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQcpg-0004RN-Ia; Sun, 17 Dec 2017 12:34:36 -0500 Original-Received: from [176.228.60.248] (port=4630 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eQcpf-00080Y-RM; Sun, 17 Dec 2017 12:34:36 -0500 In-reply-to: (message from Drew Adams on Sun, 17 Dec 2017 09:10:00 -0800 (PST)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221177 Archived-At: > Date: Sun, 17 Dec 2017 09:10:00 -0800 (PST) > From: Drew Adams > > Searching a bit more, I see that `framep' returns plain `t' > "for a termcap frame (a character-only terminal)". And the > user with this problem (in spite of non-nil `display-graphic-p') > does indeed get `t' for `(framep (selected-frame))'. > > So my next attempt will likely be to use that instead of > `display-graphic-p'. > > Before I try that, can someone please point out what I'm missing? > > The doc for both `framep' and `display-graphic-p' seems to say > that the former returns `t' for a " a character-only terminal", > and the latter returns `nil' for a "text-only terminal". But in > this user's case they apparently don't agree about his "terminal". > Is there some nuance here - a difference between a "character-only" > terminal and a "text-only" terminal? The only way I can explain how the above contradiction happens is that those 2 functions are called for different frames. On Unix an Emacs session can have both text-mode and GUI frames, and in that case it is very important to invoke each of those 2 functions with the correct frame, especially if pop-up frames are involved. > Just what are the relations between `emacs -nw', `framep' > returning `t', and `display-graphic-p' returning `nil'? "emacs -nw" doesn't directly determine the value returned by those functions. What matters is the type of frame which is the argument of these functions (by default, the selected frame at the time of the call). "emacs -nw" starts with a single text-mode frame, but on Unix it can create GUI frames on various X displays, and on those GUI frames display-graphic-p will return non-nil. > What should I be testing for here, to detect a "terminal" or > a "terminal" mode (I'm not sure just what the problematic use > case is), so that it then makes sense to check the option value? As should be apparent from the above, you logic is flawed to begin with, because a single Emacs session can have both text-mode and GUI frames. So I think you should examine the value of display-graphic-p not at key-binding time, but inside diredp-chown-this-file, because only then you know on which kind of frame will the command run.