From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: EWMH package, please review. Date: 13 Oct 2003 00:17:35 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <3F898710.9050109@swipnet.se> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1065997507 5230 80.91.224.253 (12 Oct 2003 22:25:07 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 12 Oct 2003 22:25:07 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Oct 13 00:25:05 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A8oe9-000273-00 for ; Mon, 13 Oct 2003 00:25:05 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1A8oe9-0003DQ-00 for ; Mon, 13 Oct 2003 00:25:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A8oZf-00089D-Je for emacs-devel@quimby.gnus.org; Sun, 12 Oct 2003 18:20:27 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1A8oXd-0007Hk-Tw for emacs-devel@gnu.org; Sun, 12 Oct 2003 18:18:21 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1A8oX3-00072F-6S for emacs-devel@gnu.org; Sun, 12 Oct 2003 18:18:16 -0400 Original-Received: from [193.162.153.3] (helo=pfepb.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A8oX1-00071W-Je for emacs-devel@gnu.org; Sun, 12 Oct 2003 18:17:43 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepb.post.tele.dk (Postfix) with SMTP id 747EE5EE0DD; Mon, 13 Oct 2003 00:17:42 +0200 (CEST) Original-To: "Jan D." In-Reply-To: <3F898710.9050109@swipnet.se> Original-Lines: 120 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:17050 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:17050 "Jan D." writes: > Hello. > > I've made a small package to manipulate extended window manager hints. > Since Elisp is not my biggest strength, I'd like some comments. Ok, you asked for it :-) > I > don't know if this is useful enough to be included in Emacs, so I'd > like your views on that also. I don't know. Are (all of) those hints something an ordinary user would typically toggle interactively? > ;;; Code: > > (defun x-ewmh-send (arg hint frame &optional hint2) > "Send a client message to change an extended window manager hint. > > FRAME may be nil to use the selected frame. > If ARG is poitive, add HINT. > If ARG is negative, remove HINT. > Otherwise toggle HINT." > > (let* ((eff-arg (if (null arg) 0 (prefix-numeric-value arg))) This is simpler: (setq arg (if (null arg) 0 (prefix-numeric-value arg))) (let ((action ...use ARG instead of EFF-ARG...)) IMO, it is somewhat unusual to let a generic, non-interactive function assume that it is always invoked by an interactive function. I would normally let the callers do that (possibly using an auxiliary function), but in your case I would just change the DOC string to say that ARG is supposed to be a raw prefix argument. > (action (cond ((= eff-arg 0) 2) ;; Toggle > ((> eff-arg 0) 1) ;; Add > (t 0)))) ;; Remove > (x-send-client-message nil 0 frame "_NET_WM_STATE" 32 > (list action > hint > (if hint2 hint2 0) simpler: (or hint2 0) > 0)))) > > > (defun x-ewmh-fullscreen (&optional arg frame) > "Toggle FRAME fullscreen hint using extended window manager hints (EWMH). Since this is an interactive function, you should describe the normal interactive function in the "one-liner", which in your case would mean not referring to the FRAME argument. > > If FRAME is not given, the selected frame is used. > If ARG is poitive, add fullscreen hint. > If ARG is negative, remove fullscreen hint. Since this is an interactive function, you would normally say that using a positive command prefix would add the hint and a negative prefix would remove the hint, while no prefix toggles the hint. But it might be clearer if you say that a C-u prefix (write \\[universal-argument] in the doc string) adds the hint, while a M-- prefix (write \\[negative-argument] removes the hint. > Otherwise toggle fullscreen hint. I suggest you write something like this in the doc string: "Toggle EWMH fullscreen hint of selected frame. With \\[universal-argument] prefix arg, add fullscreen hint, and with \\[negative-argument] prefix arg, remove fullscreen hint. When called from a Lisp program, optional second arg FRAME specifies the frame on which to apply the fullscreen hint." > > If fullscreen doesn't work with your window manager, try > `x-ewmh-horz-and-vert'. > > NOTE: If the window manager does not support EWMH, this does nothing." > (interactive "P") > (x-ewmh-send arg "_NET_WM_STATE_FULLSCREEN" frame)) > > > (defun x-ewmh-maximized_vert (&optional arg frame) x-ewmh-maximized-vertical (don't use underscore and write name in full) > > (defun x-ewmh-maximized_horz (&optional arg frame) x-ewmh-maximized-horizontal (ditto) > > (defun x-ewmh-horz-and-vert (&optional arg frame) x-ewmh-horizontal-and-vertical (ditto) Maybe in general, the functions should be named x-ewmh-toggle-... to emphasize that their default operation is to toggle the hint. -- Kim F. Storm http://www.cua.dk