Need help remove uneccesary FunctionCalls...

This is a piece of code i found on the net, i have simplified it as much as it is possible up to my knoweledge.

DestroyFunc EdgeFunction
AddToFunc EdgeFunction
+ I Deschedule 30
+ I Deschedule 31
+ I $*

DestroyFunc ShowPager
AddToFunc ShowPager
+ I All (FvwmPager) Move $0 $1

DestroyFunc SetEdges
AddToFunc SetEdges
+ I Deschedule 30
+ I Deschedule 31
+ I EdgeCommand North EdgeFunction ShowPager m-80p m40p
+ I EdgeCommand West EdgeFunction ShowPager m40p m-80p
+ I EdgeCommand East EdgeFunction ShowPager m-200p m-80p

As i have no use for the separate functions i want to avoid overhead so my target is put them together in one function.
Please can i get some help simplyfie the SetEdges function so i can remove the calls to ShowPager and EdgeFunction (then i will rename Setedges to ShowPager - but that is another story)

It seems that SetEdges is needed to be on Bottom of SetEdges Function - i have trying remove it - without success because i don’t understand what it does there, does the Function call itself.?
I don’t ask you to rewrite the code for me, what i need is some better understanding about the parametercalls.

ps - i hope this code fits under the term “Small pieces of code for inclusion in questions/answers is fine though.”,


You can use “Move $*” in place of “Move $0 $1”.

There’s no need to simplify it – it’s OK as it is.

– Thomas Adam

I’m just going to jump to conclusions, and decide that you are a newcomer to not only fvwm, but *NIX aswell. If it’s the wrong conclusion, well, I’m sorry.
I’ll just try to help you on a more general level, since you are most probably going to hit quite a few walls during your endaveours in the fvwm incase you’re new to it (or new to *NIX in general).
I hope that the over-quoting of the man-page doesn’t offend anyone. I promise not to make a habit of it.

The above piece of code adds to the function named EdgeFunction. For information on complex functions, do man fvwm, and press the slash -key ("/") to start searching. Search for “COMMANDS FOR USER FUNCTIONS AND SHELL COMMANDS”. I make these inside quotes by separating the search from man -command by a “;” from here on out.

(“I” stands for “Immediate”.)

The above piece of code adds to the function named ShowPager.

I believe that after reading the above manpage quotes, you are able to understand how the functions are built up. I also believe that taking some complex configuration made by someone else and start slicing and digesting it, can be a rather hard way to start learning.

But that’s just me.

Ahh - yes…

I think i should be more specific in my way to ask…

I want it as simplifyed as possible, because that makes it easier for me as a newcomer to understand how its all is put together.

+ I EdgeCommand North EdgeFunction ShowPager m-80p m40p

I dont realy get what is the parameters and what is the separate functioncalls
As i understand it - EdgeCommand can take one or two parameters, and afteer what i see there there parameters and functions mixed all together.

If you could be nice and write it in kinda pseudo c it should be easier to me to understand it.
Like this (probably i didn’t get it right here…

EdgeCommand( North EdgeFunction) ShowPager (m-80p m40p )
if thats right, then i am not less confused - does fvwm accept multiple command in one lite.?

Is I EdgeCommand North EdgeFunction ShowPager m-80p m40p
equal to

I EdgeCommand North EdgeFunction I ShowPager m-80p m40p

I think i am completely lost here…


That doesn’t matter, and nor should it. EdgeCommand accepts two parameters – the direction (area of the screen, if you will) and a command to act upon once that condition has been satisfied. That command could be anything – another builtin command, or a complex function (as is the case with your example above).

So we see that we’re calling EdgeFunction, and passing it: “ShowPager m-80p m40p” as parameters. Note that the whole point of complex functions is that to the user, they don’t need to know or care whether the function is just that, or a pre-existing command builtin to FVWM. The only reason we differentiate is for a social and technical reaon; social in that quite often the person using the function wrote it, so they know it’s one through design, and technical because functions have a context associated with them which can affect the operand windows they run on.

I’ve described this concept before anyway: function chaining – the propagation of events from one function to another. There are inherent dangers in doing this, but consider:

DestroyFunc A
AddToFunc A
+ I Function B $*

DestroyFunc B
AddToFunc B 
+ I Echo $0
+ I Exec exec $*

Yes, A calls B in this case, passing down various things, but so what? It doesn’t matter to you how it works, just that A accepts some parameters in the first place.

Correct – see above.

I’d rather not, if only because trying to describe FVWM in terms of the BNF is pointless; it’s not a programming language, and you shouldn’t try to see it as such. The confusion you’re in probably stems from the fact you think that it can work like a program. But it doesn’t.

– Thomas Adam

It is as simple as the man page says. I am not going to quote it here. It is as easy as to do “man fvwm” and then press ‘/’ and write “EdgeCommand”. It is the first instance of that string in the man page.

If you look at the man page, you will see that EdgeCommand waits for two arguments: a direction, and fvwm command. The second argument (the fvwm command) can be, itself, as complex as any other fvwm that you would put into a single line without EdgeCommand.

So, to understand that line, you need the full code from the first post:

[code]DestroyFunc EdgeFunction
AddToFunc EdgeFunction

  • I Deschedule 30
  • I Deschedule 31
  • I $*

DestroyFunc ShowPager
AddToFunc ShowPager

  • I All (FvwmPager) Move $0 $1

DestroyFunc SetEdges
AddToFunc SetEdges

  • I Deschedule 30
  • I Deschedule 31
  • I EdgeCommand North EdgeFunction ShowPager m-80p m40p
  • I EdgeCommand West EdgeFunction ShowPager m40p m-80p
  • I EdgeCommand East EdgeFunction ShowPager m-200p m-80p

The EdgeCommand lines, logically, start with “EdgeCommand”, the thing after that, is the direction (first argument of EdgeCommand), the rest of the line, is the action you want to run when the mouse touches the border that the first argument refers to.

To know what “EdgeFunction ShowPager m-80p m40p” you will need, of course, to look into that function (EdgeFunction), which is defined above. And to know what that function will do, in turn, you will need to look the other function, called “ShowPager”.

Translating this to C would not help, because it would be a totally arbitrary interpretation on my side. The logic behind the C language and the FVWM syntax is very different, for a comparison to be of any use.

No, it is just that some Fvwm commands, need another command or a function as an argument.

The rest of the post is not something relevant to comment, since you might already see it a bit more clearly now. If not, just ask, but first, look into the Fvwm man page and see the EdgeCommand part. You also need to understand what a function is and how they work in Fvwm. As Thomas Adam says, there is no need to further optimize of simplify this code snippet. It is already efficient and works on its current form.

– Jesús Guerrero.

Yes i am a newcomer - and i am glad for all the help i can get.
Well - to be honest, i have had short rendewouz with Linux/Unix in test installs a few weeks every past year or so - but i didnt have time or hardware to play around with it because my customers use M$ products.
But now i have felt it is time for me play with *nix for real so i have installed Gentoo in two of my old boxes and recently i spent this weekend installing and configuring Solaris in the third one - and i can’t wait until i got two hardware (cpus and memmory) so i can install Debian (i gonna run Unstable there) and in the fifth one i will do a LFS (Linux From Scratch) Install.
None of my *nix machines are faster than 531 Mhz.


In fact, i have read all theese manpages before- but i did it the same night right before i started this thread, so it is all new to me.

I think i got out the most of them, but when it comes to longer parts it is not easy to me - as English is not my first language, i guess you could tell :slight_smile: ., therefore it was god for me to see all that again.
AND as i have to read and reread the manpages with theese functions it is good for me to have them put together as you did, it makes it a little more comfortable for me to get the m read in situations where i should have scrubbed my head instead.

Maybe you are right, but as there was the only place i could find the ansver how to solve my problem, which was ‘how to make a pager popup as the cursor touch the edges of the screen’

And also - if you carefully read the originalfile you will see that i have made quite good succes rewrite his functions.
And as some of his ideas -for ex " Windows operations such as moving, resizing, etc are executed by clicking anywhere on the window border or, with the Windows Key pressed, anywhere in the window. Most useful mouse bindings:"
is similar to mine, his whole config was a great input for me to get inspiration from in the future.
He have som great ideas and programs on his site - for example, a tool where you can position the mouse-cursor just moving your eyes (Through a web-cam)

Well - i was getting offtopic again, sorry.


I understand that - it is just that it is a new concept to me, what i realy don’t get is, If a function take n parameters where some of the parameters can be functions and i then call next function in the same line - how can i tell just by reading which is what and how can the input function understant that the next function is not a parameter.

I suppose that it don’t works like a program because it doesn’t return a value.?
Well - probably you have gave me as a good ansver as possible, maybe i just have to get used by write more and better configs.
I guess that in a few weeks i will look at this posting asking myself - how could i ask such obvious things.


Thomas Adam, Please forget this, as i read your post i understand that my questiom here was pointless.