unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: EWMH package, please review.
Date: 13 Oct 2003 00:17:35 +0200	[thread overview]
Message-ID: <m3ekxi5ce8.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <3F898710.9050109@swipnet.se>

"Jan D." <jan.h.d@swipnet.se> 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 <storm@cua.dk> http://www.cua.dk

  reply	other threads:[~2003-10-12 22:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-12 16:53 EWMH package, please review Jan D.
2003-10-12 22:17 ` Kim F. Storm [this message]
2003-10-12 22:54   ` Miles Bader
2003-10-13  4:34     ` Jan D.
2003-10-13  4:30   ` Jan D.
2003-10-13  7:54     ` David Kastrup
2003-10-13  8:43     ` Thien-Thi Nguyen
2003-10-18 17:47       ` Jan D.
2003-10-18 18:05         ` David Kastrup
2003-10-18 18:15           ` David Kastrup
2003-10-27  5:56           ` Jan D.
2003-10-13 18:21   ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ekxi5ce8.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).