* Making sure I'm not checking email (or doing other things) too often
@ 2016-02-14 21:05 Marcin Borkowski
2016-02-15 1:29 ` Emanuel Berg
2016-02-15 14:40 ` Michael Heerdegen
0 siblings, 2 replies; 22+ messages in thread
From: Marcin Borkowski @ 2016-02-14 21:05 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi all,
thanks to Michael Heerdegen, my code is now working, and even though it
is not finished, I'm quite happy/proud of it. I will finish it within
a week or two and blog about it, but please let me show the current
state here, especially that I suspect a few people could find it handy.
The problem: I hit U (mu4e-update-mail-and-index) way too often. I want
Emacs to help me fight this unproductive habit.
Also, I'm a mathematician, and I want to have a general solution to the
problem of launching certain commands too often.
So, here is my current solution. It is not perfect, I will tinker with
it a bit more later.
--8<---------------cut here---------------start------------->8---
(defun not-too-often-add-guard (fun interval)
"Add a not-too-often guard to FUN with INTERVAL.
This means that if FUN gets called less than INTERVAL minutes
after last call, the use is asked whether s?he really wants to
run the command."
(let* ((fun-name (symbol-name fun))
(nto-int-sym
(intern (concat "not-too-often-interval-" fun-name)))
(nto-last-time-sym
(intern (concat "not-too-often-last-time-" fun-name)))
(nto-guard-sym
(intern (concat "not-too-often-guard-" fun-name))))
(set nto-int-sym interval)
(set nto-last-time-sym 0)
(fset nto-guard-sym (lambda (orig-fun &rest args)
(let ((elapsed (time-to-seconds
(time-subtract
(current-time)
(symbol-value nto-last-time-sym)))))
(if (< elapsed
(* 60 (symbol-value nto-int-sym)))
(cond ((y-or-n-p
(format "You called %s %s minutes ago. Are you sure you want to proceed? "
fun-name (/ elapsed 60.0)))
(set nto-last-time-sym (current-time))
(apply orig-fun args))
(t
(keyboard-quit)))
(set nto-last-time-sym (current-time))))))
(put nto-guard-sym 'function-documentation
(format
"Issue a warning if function `%s' is called less than %s minutes from last call."
fun-name interval))
(advice-add fun :around nto-guard-sym)))
--8<---------------cut here---------------end--------------->8---
Now I can say e.g.
(not-too-often-add-guard 'mu4e-update-mail-and-index 15)
and have Emacs warn me if I want to check for new email sooner than 15
minutes after last time.
Opinions welcome.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-14 21:05 Making sure I'm not checking email (or doing other things) too often Marcin Borkowski
@ 2016-02-15 1:29 ` Emanuel Berg
2016-02-15 15:21 ` Marcin Borkowski
[not found] ` <mailman.4745.1455549737.843.help-gnu-emacs@gnu.org>
2016-02-15 14:40 ` Michael Heerdegen
1 sibling, 2 replies; 22+ messages in thread
From: Emanuel Berg @ 2016-02-15 1:29 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> The problem: I hit U (mu4e-update-mail-and-index)
> way too often. I want Emacs to help me fight this
> unproductive habit.
The solution: every time you do it - I assume you hit
the final `u' with your right index finger - instantly
slap your right hand as hard as you can with your
left hand.
The only time you will not punish yourself this way is
when you peace and quiet and with no rush to it
beforehand thinks "yes, now is the time to check the
mail!" - and then you do it.
> Also, I'm a mathematician, and I want to have
> a general solution to the problem of launching
> certain commands too often.
It is more something an engineer would do so perhaps
you are that at heart.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-14 21:05 Making sure I'm not checking email (or doing other things) too often Marcin Borkowski
2016-02-15 1:29 ` Emanuel Berg
@ 2016-02-15 14:40 ` Michael Heerdegen
2016-02-15 14:58 ` Marcin Borkowski
2016-03-06 13:26 ` Marcin Borkowski
1 sibling, 2 replies; 22+ messages in thread
From: Michael Heerdegen @ 2016-02-15 14:40 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> (defun not-too-often-add-guard (fun interval)
> "Add a not-too-often guard to FUN with INTERVAL.
> This means that if FUN gets called less than INTERVAL minutes
> after last call, the use is asked whether s?he really wants to
> run the command."
> (let* ((fun-name (symbol-name fun))
> (nto-int-sym
> (intern (concat "not-too-often-interval-" fun-name)))
> (nto-last-time-sym
> (intern (concat "not-too-often-last-time-" fun-name)))
> (nto-guard-sym
> (intern (concat "not-too-often-guard-" fun-name))))
> (set nto-int-sym interval)
> (set nto-last-time-sym 0)
> (fset nto-guard-sym (lambda (orig-fun &rest args)
> (let ((elapsed (time-to-seconds
> (time-subtract
> (current-time)
> (symbol-value nto-last-time-sym)))))
> (if (< elapsed
> (* 60 (symbol-value nto-int-sym)))
> (cond ((y-or-n-p
> (format "You called %s %s minutes ago. Are you sure you want to proceed? "
> fun-name (/ elapsed 60.0)))
> (set nto-last-time-sym (current-time))
> (apply orig-fun args))
> (t
> (keyboard-quit)))
> (set nto-last-time-sym (current-time))))))
> (put nto-guard-sym 'function-documentation
> (format
> "Issue a warning if function `%s' is called less than %s minutes from last call."
> fun-name interval))
> (advice-add fun :around nto-guard-sym)))
>
> Now I can say e.g.
>
> (not-too-often-add-guard 'mu4e-update-mail-and-index 15)
>
> and have Emacs warn me if I want to check for new email sooner than 15
> minutes after last time.
>
> Opinions welcome.
That looks very good!
[ An alternative approach would be to make `not-too-often-add-guard' a
macro. This would avoid the need of using `symbol-value' which some
find not aesthetic, but that's more a matter of personal taste, and you
surely know that already. ]
FWIW, the functionality "let a command behave differently depending on
how much time since its last invocation has elapsed" is useful in other
contexts too. E.g. when you want to make a key to behave differently
when you hit it multiple times in fast succession.
Factoring out the greatest common divider would give you something like
this:
--8<---------------cut here---------------start------------->8---
-*- lexical-binding: t -*-
(defun stopwatch ()
"Return a fresh stopwatch.
This is a function accepting zero arguments that upon each call
will return the time difference from its last call in seconds.
When called the first time it will return nil."
(let ((last-invocation nil))
(lambda ()
(prog1 (and last-invocation
(time-to-seconds (time-subtract (current-time) last-invocation)))
(setq last-invocation (current-time))))))
--8<---------------cut-here---------------end--------------->8---
With that, one could make your advice functions reference and use such a
stopwatch object (each an individual one, of course).
Regards,
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 14:40 ` Michael Heerdegen
@ 2016-02-15 14:58 ` Marcin Borkowski
2016-02-15 15:08 ` Michael Heerdegen
2016-03-06 13:26 ` Marcin Borkowski
1 sibling, 1 reply; 22+ messages in thread
From: Marcin Borkowski @ 2016-02-15 14:58 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
On 2016-02-15, at 15:40, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> (defun not-too-often-add-guard (fun interval)
>> "Add a not-too-often guard to FUN with INTERVAL.
>> This means that if FUN gets called less than INTERVAL minutes
>> after last call, the use is asked whether s?he really wants to
>> run the command."
>> (let* ((fun-name (symbol-name fun))
>> (nto-int-sym
>> (intern (concat "not-too-often-interval-" fun-name)))
>> (nto-last-time-sym
>> (intern (concat "not-too-often-last-time-" fun-name)))
>> (nto-guard-sym
>> (intern (concat "not-too-often-guard-" fun-name))))
>> (set nto-int-sym interval)
>> (set nto-last-time-sym 0)
>> (fset nto-guard-sym (lambda (orig-fun &rest args)
>> (let ((elapsed (time-to-seconds
>> (time-subtract
>> (current-time)
>> (symbol-value nto-last-time-sym)))))
>> (if (< elapsed
>> (* 60 (symbol-value nto-int-sym)))
>> (cond ((y-or-n-p
>> (format "You called %s %s minutes ago. Are you sure you want to proceed? "
>> fun-name (/ elapsed 60.0)))
>> (set nto-last-time-sym (current-time))
>> (apply orig-fun args))
>> (t
>> (keyboard-quit)))
>> (set nto-last-time-sym (current-time))))))
>> (put nto-guard-sym 'function-documentation
>> (format
>> "Issue a warning if function `%s' is called less than %s minutes from last call."
>> fun-name interval))
>> (advice-add fun :around nto-guard-sym)))
>>
>> Now I can say e.g.
>>
>> (not-too-often-add-guard 'mu4e-update-mail-and-index 15)
>>
>> and have Emacs warn me if I want to check for new email sooner than 15
>> minutes after last time.
>>
>> Opinions welcome.
>
> That looks very good!
Thanks! (Alas, there's a nasty bug. But it'll be polished out.)
> [ An alternative approach would be to make `not-too-often-add-guard' a
> macro. This would avoid the need of using `symbol-value' which some
> find not aesthetic, but that's more a matter of personal taste, and you
> surely know that already. ]
I did not even consider it, because what I want to do is to feed
`not-too-often-add-guard' to mapc. The assumption is that the user will
have an alist of command/time interval pairs.
> FWIW, the functionality "let a command behave differently depending on
> how much time since its last invocation has elapsed" is useful in other
> contexts too. E.g. when you want to make a key to behave differently
> when you hit it multiple times in fast succession.
Nice, I didn't think about it.
> Factoring out the greatest common divider would give you something like
> this:
>
> --8<---------------cut here---------------start------------->8---
> -*- lexical-binding: t -*-
>
> (defun stopwatch ()
> "Return a fresh stopwatch.
> This is a function accepting zero arguments that upon each call
> will return the time difference from its last call in seconds.
> When called the first time it will return nil."
> (let ((last-invocation nil))
> (lambda ()
> (prog1 (and last-invocation
> (time-to-seconds (time-subtract (current-time) last-invocation)))
> (setq last-invocation (current-time))))))
> --8<---------------cut-here---------------end--------------->8---
>
> With that, one could make your advice functions reference and use such a
> stopwatch object (each an individual one, of course).
Thanks, I'll probably make use of it, if you have nothing against (I
plan to eventually put this on Melpa).
> Regards,
>
> Michael.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 14:58 ` Marcin Borkowski
@ 2016-02-15 15:08 ` Michael Heerdegen
2016-02-15 15:18 ` Marcin Borkowski
0 siblings, 1 reply; 22+ messages in thread
From: Michael Heerdegen @ 2016-02-15 15:08 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> > [ An alternative approach would be to make `not-too-often-add-guard' a
> > macro. This would avoid the need of using `symbol-value' which some
> > find not aesthetic, but that's more a matter of personal taste, and you
> > surely know that already. ]
>
> I did not even consider it, because what I want to do is to feed
> `not-too-often-add-guard' to mapc. The assumption is that the user will
> have an alist of command/time interval pairs.
You would just use `dolist' or a lambda wrapper around the macro call
(with the current signature, you can't `mapc' your function over an
alist directly anyway).
> Thanks, I'll probably make use of it, if you have nothing against (I
> plan to eventually put this on Melpa).
I don't care.
Regards,
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 15:08 ` Michael Heerdegen
@ 2016-02-15 15:18 ` Marcin Borkowski
0 siblings, 0 replies; 22+ messages in thread
From: Marcin Borkowski @ 2016-02-15 15:18 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
On 2016-02-15, at 16:08, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> > [ An alternative approach would be to make `not-too-often-add-guard' a
>> > macro. This would avoid the need of using `symbol-value' which some
>> > find not aesthetic, but that's more a matter of personal taste, and you
>> > surely know that already. ]
>>
>> I did not even consider it, because what I want to do is to feed
>> `not-too-often-add-guard' to mapc. The assumption is that the user will
>> have an alist of command/time interval pairs.
>
> You would just use `dolist' or a lambda wrapper around the macro call
> (with the current signature, you can't `mapc' your function over an
> alist directly anyway).
You're right.
>> Thanks, I'll probably make use of it, if you have nothing against (I
>> plan to eventually put this on Melpa).
>
> I don't care.
Thanks, and thanks again for your help.
> Regards,
>
> Michael.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 1:29 ` Emanuel Berg
@ 2016-02-15 15:21 ` Marcin Borkowski
2016-02-15 16:32 ` tomas
2016-02-16 0:37 ` Emanuel Berg
[not found] ` <mailman.4745.1455549737.843.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 22+ messages in thread
From: Marcin Borkowski @ 2016-02-15 15:21 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
On 2016-02-15, at 02:29, Emanuel Berg <embe8573@student.uu.se> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> The problem: I hit U (mu4e-update-mail-and-index)
>> way too often. I want Emacs to help me fight this
>> unproductive habit.
>
> The solution: every time you do it - I assume you hit
> the final `u' with your right index finger - instantly
> slap your right hand as hard as you can with your
> left hand.
>
> The only time you will not punish yourself this way is
> when you peace and quiet and with no rush to it
> beforehand thinks "yes, now is the time to check the
> mail!" - and then you do it.
Not funny.
>> Also, I'm a mathematician, and I want to have
>> a general solution to the problem of launching
>> certain commands too often.
>
> It is more something an engineer would do so perhaps
> you are that at heart.
I thought I knew who I am.
Now I don't know that anymore.
Even less funny.
Thank you so much.
:-P
Just kidding, to make things clear. But with a grain of truth. We
mathematicians tend to make fun of engineers. I used to do that, too.
(I still do that, it's soooo much fun.) But OTOH, engineers are cooler
than pure mathematicians in one respect: they (sometimes) come up with
solutions - sometimes ugly, sometimes stupid - to /real world problems/.
Hard to beat that.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 15:21 ` Marcin Borkowski
@ 2016-02-15 16:32 ` tomas
2016-02-16 0:48 ` Emanuel Berg
2016-02-16 0:37 ` Emanuel Berg
1 sibling, 1 reply; 22+ messages in thread
From: tomas @ 2016-02-15 16:32 UTC (permalink / raw)
To: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mon, Feb 15, 2016 at 04:21:55PM +0100, Marcin Borkowski wrote:
[...]
> I thought I knew who I am.
>
> Now I don't know that anymore.
>
> Even less funny.
>
> Thank you so much.
Mathematician, engineer... Mathematicians are the engineers of
abstraction (/me runs for cover)
regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlbB/YsACgkQBcgs9XrR2kawHwCeOGhqVCd4km02htNPuySXddk6
M4YAnjNOyqGDrGawF6b6eRB6BP2mpY8n
=D03X
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
[not found] ` <mailman.4745.1455549737.843.help-gnu-emacs@gnu.org>
@ 2016-02-15 21:10 ` Joost Kremers
2016-02-16 0:56 ` Emanuel Berg
2016-02-17 13:42 ` Rusi
0 siblings, 2 replies; 22+ messages in thread
From: Joost Kremers @ 2016-02-15 21:10 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski wrote:
> But OTOH, engineers are cooler
> than pure mathematicians in one respect: they (sometimes) come up with
> solutions - sometimes ugly, sometimes stupid - to /real world problems/.
> Hard to beat that.
Bah. Real world is overrated.
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 15:21 ` Marcin Borkowski
2016-02-15 16:32 ` tomas
@ 2016-02-16 0:37 ` Emanuel Berg
1 sibling, 0 replies; 22+ messages in thread
From: Emanuel Berg @ 2016-02-16 0:37 UTC (permalink / raw)
To: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
>>> The problem: I hit U (mu4e-update-mail-and-index)
>>> way too often. I want Emacs to help me fight this
>>> unproductive habit.
>>
>> The solution: every time you do it - I assume you
>> hit the final `u' with your right index finger -
>> instantly slap your right hand as hard as you can
>> with your left hand. The only time you will not
>> punish yourself this way is when you peace and
>> quiet and with no rush to it beforehand thinks
>> "yes, now is the time to check the mail!" - and
>> then you do it.
>
> Not funny.
But it works.
If you want an "Emacs" solution you can simply assign
a much *longer* shortcut, like three strikes and
perhaps involving the functions keys or something as
un-ergonomic.
The first time you strike it (without wanting to) it
will take some additional time compared to 'U', so
half thru the sequence (or so) you'll be able to stop.
The next time you do it you will remember (your brain
will at some level) that the previous time you did
stop. So this time you will stop not half thru the
sequence but 1/3 in.
And so on until you do not even initiate the hand
movement to do it. At that time there is only the
thought left, which will disappear exactly the
same way.
This is actually not that different from the
"slapping" solution. It is all about associating with
some thing else - pain, or "incompleteness" of the
action - here, they fill the same spot.
> engineers are cooler than pure mathematicians in one
> respect: they (sometimes) come up with solutions -
> sometimes ugly, sometimes stupid - to /real world
> problems/. Hard to beat that.
Indeed. For example:
http://user.it.uu.se/~embe8573/pics/door.jpg
But, what engineers and mathematicians do or do not do
*in general* I'd be damned to say. Specifically, when
mathematicians do Lisp they are more engineers than
mathematicians, save for if the Lisp has some
application to math or DP-ish computation, in which
case they are a bit of both.
And this is how it should be! It it like the NHL
playoff. To win it, goal scorers have to check and
checkers have to score goals...
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 16:32 ` tomas
@ 2016-02-16 0:48 ` Emanuel Berg
2016-02-16 7:38 ` tomas
0 siblings, 1 reply; 22+ messages in thread
From: Emanuel Berg @ 2016-02-16 0:48 UTC (permalink / raw)
To: help-gnu-emacs; +Cc: Dag Holmgren
<tomas@tuxteam.de> writes:
> Mathematician, engineer... Mathematicians are the
> engineers of abstraction (/me runs for cover)
What is that joke?
Biology is applied chemistry which is applied physics
which is applied math which is applied logic!
But only inexperienced (young) people deduct from this
that logic is "purer" or cooler than biology...
Just venture into an old-growth forest ("ancient
woodland" to the UK people) and see for yourself what
is cooler... (It is "urskog" in Swedish which is
"paleo forest" or "primeval forest" which - the
second - is listed on the Wikipedia page for
"old-growth forest" [1] as meaning the same.)
This definition is better: If it's still, it is
physics. If it moves, it is biology. And if it blows
up, it is chemistry!
:)
"What a reaction!"
[1] https://en.wikipedia.org/wiki/Old-growth_forest
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 21:10 ` Joost Kremers
@ 2016-02-16 0:56 ` Emanuel Berg
2016-02-17 13:42 ` Rusi
1 sibling, 0 replies; 22+ messages in thread
From: Emanuel Berg @ 2016-02-16 0:56 UTC (permalink / raw)
To: help-gnu-emacs
Joost Kremers <joost.m.kremers@gmail.com> writes:
>> But OTOH, engineers are cooler than pure
>> mathematicians in one respect: they (sometimes)
>> come up with solutions - sometimes ugly, sometimes
>> stupid - to /real world problems/. Hard to
>> beat that.
>
> Bah. Real world is overrated.
Dig a hole, remove all the reed, make a wall with
stones and clay, then raise a palisade and fill the
hole with water and watch the birds come.
After doing that two weeks, tell me if you feel
a pressing need to stare into a monitor and
push buttons!
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-16 0:48 ` Emanuel Berg
@ 2016-02-16 7:38 ` tomas
2016-02-17 2:38 ` Emanuel Berg
0 siblings, 1 reply; 22+ messages in thread
From: tomas @ 2016-02-16 7:38 UTC (permalink / raw)
To: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tue, Feb 16, 2016 at 01:48:29AM +0100, Emanuel Berg wrote:
> <tomas@tuxteam.de> writes:
>
> > Mathematician, engineer... Mathematicians are the
> > engineers of abstraction (/me runs for cover)
>
> What is that joke?
> [...] And if it blows up, it is chemistry!
That's why I was running for cover. I *knew* it would end blowing up.
It always does ;-P
regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlbC0ecACgkQBcgs9XrR2ka2OACdHpuo4iazwaeXOhiYY8bv65sT
GpkAnieiCBAOdw0z1QaPX/03c/y3XWhv
=GdoF
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-16 7:38 ` tomas
@ 2016-02-17 2:38 ` Emanuel Berg
0 siblings, 0 replies; 22+ messages in thread
From: Emanuel Berg @ 2016-02-17 2:38 UTC (permalink / raw)
To: help-gnu-emacs
<tomas@tuxteam.de> writes:
>>> Mathematician, engineer... Mathematicians are the
>>> engineers of abstraction (/me runs for cover)
>>
>> What is that joke? [...] And if it blows up, it
>> is chemistry!
>
> That's why I was running for cover. I *knew* it
> would end blowing up. It always does ;-P
Math is sort of cool especially if you have several
huge whiteboards and can spend hours drawing figures
perfectly and write down even the most basic
connection without having to erase anything until you
are done.
Problem is pretty soon I think you will reach a level
where only a few people can take an interest in what
you do. Because it is advanced, yes, but also because
of the nature of it.
Compare this to programming. If you do something
really advanced, like Quake or the F/A-18 Hornet
simulator, despite the 'advancedness', thousands of
people, from kid to professor can understand and
enjoy and even learn from it.
On the other hand, even tho you consider yourself an
advanced programmer, you can do something trivial like
what I just did in the other thread:
(defun info-lookup-elisp-symbol (symbol)
(interactive "Ssymbol: ")
(info-lookup-symbol symbol 'emacs-lisp-mode))
It is trivial, but like I said, if you do it every
day, an advanced person can benefit from the advanced
programmer's trivial code, because he/she (not the
programmer) can then not have to focus on that but put
his/her mind to whatever is advanced!
On the third hand, because programming isn't really
difficult, perhaps we *should* encourage people to
take up math. I mean, they can do programming in their
spare time :)
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 21:10 ` Joost Kremers
2016-02-16 0:56 ` Emanuel Berg
@ 2016-02-17 13:42 ` Rusi
2016-02-18 0:24 ` Emanuel Berg
1 sibling, 1 reply; 22+ messages in thread
From: Rusi @ 2016-02-17 13:42 UTC (permalink / raw)
To: help-gnu-emacs
On Tuesday, February 16, 2016 at 2:40:09 AM UTC+5:30, Joost Kremers wrote:
> Marcin Borkowski wrote:
> > But OTOH, engineers are cooler
> > than pure mathematicians in one respect: they (sometimes) come up with
> > solutions - sometimes ugly, sometimes stupid - to /real world problems/.
> > Hard to beat that.
>
> Bah. Real world is overrated.
Saw this in someone's signature (cant trace exact source):
"Real world" is a phrase that cannot be written without quotation marks
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-17 13:42 ` Rusi
@ 2016-02-18 0:24 ` Emanuel Berg
0 siblings, 0 replies; 22+ messages in thread
From: Emanuel Berg @ 2016-02-18 0:24 UTC (permalink / raw)
To: help-gnu-emacs
Rusi <rustompmody@gmail.com> writes:
>> Bah. Real world is overrated.
>
> Saw this in someone's signature (cant trace exact
> source):
>
> "Real world" is a phrase that cannot be written
> without quotation marks
Everything is as "real" but what is generally implied
is the volume and diversity of sensory input, of
emotional and creative responses and actions...
So a PNG depicting a girl in a downsuit on a sailboat
with Novaya Zemlya in the background - it is a real
picture alright but what it depicts is something else
just the same.
Show this picture to ten teenagers and perhaps four
will say: "So she is doing the Northeast passage.
Big deal." and six will say "That looks insane,
I could never do anything even remote to that!"
Both attitudes are unhealthy and this is what happens
if you live your life thru the monitor only.
Your world view gets skew.
Computers are great fun and an awesome tool for many
things but they shouldn't be a substitute for things
that have nothing to do with computers. This makes the
computer look bad and the "things" even more so.
But I'm confident this is a stage only. The kids will
snap out of it. They always do :)
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-02-15 14:40 ` Michael Heerdegen
2016-02-15 14:58 ` Marcin Borkowski
@ 2016-03-06 13:26 ` Marcin Borkowski
2016-03-06 13:36 ` Marcin Borkowski
2016-03-06 13:39 ` Michael Heerdegen
1 sibling, 2 replies; 22+ messages in thread
From: Marcin Borkowski @ 2016-03-06 13:26 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
On 2016-02-15, at 15:40, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Factoring out the greatest common divider would give you something like
> this:
>
> --8<---------------cut here---------------start------------->8---
> -*- lexical-binding: t -*-
>
> (defun stopwatch ()
> "Return a fresh stopwatch.
> This is a function accepting zero arguments that upon each call
> will return the time difference from its last call in seconds.
> When called the first time it will return nil."
> (let ((last-invocation nil))
> (lambda ()
> (prog1 (and last-invocation
> (time-to-seconds (time-subtract (current-time) last-invocation)))
> (setq last-invocation (current-time))))))
> --8<---------------cut-here---------------end--------------->8---
>
> With that, one could make your advice functions reference and use such a
> stopwatch object (each an individual one, of course).
Thanks. This is my version:
(defun create-stopwatch ()
"Return a closure which returns time (in seconds) since its
last invocation every time it is called."
(let (last-invocation-time (current-time))
(lambda ()
(prog1
(time-to-seconds (time-subtract (current-time) last-invocation-time))
(setq last-invocation-time (current-time))))))
I don't claim it to be better, but I noticed a strange phenomenon. When
I invoke the "stopwatch object" (closure, in fact) for the first time,
I get negative result. Why is that so?
> Regards,
>
> Michael.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-03-06 13:26 ` Marcin Borkowski
@ 2016-03-06 13:36 ` Marcin Borkowski
2016-03-06 13:59 ` Michael Heerdegen
2016-03-06 13:39 ` Michael Heerdegen
1 sibling, 1 reply; 22+ messages in thread
From: Marcin Borkowski @ 2016-03-06 13:36 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
On 2016-03-06, at 14:26, Marcin Borkowski <mbork@mbork.pl> wrote:
> On 2016-02-15, at 15:40, Michael Heerdegen <michael_heerdegen@web.de> wrote:
>
>> Factoring out the greatest common divider would give you something like
>> this:
>>
>> --8<---------------cut here---------------start------------->8---
>> -*- lexical-binding: t -*-
>>
>> (defun stopwatch ()
>> "Return a fresh stopwatch.
>> This is a function accepting zero arguments that upon each call
>> will return the time difference from its last call in seconds.
>> When called the first time it will return nil."
>> (let ((last-invocation nil))
>> (lambda ()
>> (prog1 (and last-invocation
>> (time-to-seconds (time-subtract (current-time) last-invocation)))
>> (setq last-invocation (current-time))))))
>> --8<---------------cut-here---------------end--------------->8---
>>
>> With that, one could make your advice functions reference and use such a
>> stopwatch object (each an individual one, of course).
>
> Thanks. This is my version:
>
> (defun create-stopwatch ()
> "Return a closure which returns time (in seconds) since its
> last invocation every time it is called."
> (let (last-invocation-time (current-time))
> (lambda ()
> (prog1
> (time-to-seconds (time-subtract (current-time) last-invocation-time))
> (setq last-invocation-time (current-time))))))
>
> I don't claim it to be better, but I noticed a strange phenomenon. When
> I invoke the "stopwatch object" (closure, in fact) for the first time,
> I get negative result. Why is that so?
Never mind, I'm an idiot.
BTW: could the byte compiler warn about using
(let (var)
...)
instead of
(let ((var))
...)
?
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-03-06 13:26 ` Marcin Borkowski
2016-03-06 13:36 ` Marcin Borkowski
@ 2016-03-06 13:39 ` Michael Heerdegen
2016-03-06 14:09 ` Marcin Borkowski
1 sibling, 1 reply; 22+ messages in thread
From: Michael Heerdegen @ 2016-03-06 13:39 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> (defun create-stopwatch ()
> "Return a closure which returns time (in seconds) since its
> last invocation every time it is called."
> (let (last-invocation-time (current-time))
> (lambda ()
> (prog1
> (time-to-seconds (time-subtract (current-time) last-invocation-time))
> (setq last-invocation-time (current-time))))))
>
> I don't claim it to be better, but I noticed a strange phenomenon. When
> I invoke the "stopwatch object" (closure, in fact) for the first time,
> I get negative result. Why is that so?
Eehm, eh...looks like your let bindings are not what you intended...
Ask the byte compiler!
Regards,
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-03-06 13:36 ` Marcin Borkowski
@ 2016-03-06 13:59 ` Michael Heerdegen
0 siblings, 0 replies; 22+ messages in thread
From: Michael Heerdegen @ 2016-03-06 13:59 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> BTW: could the byte compiler warn about using
>
> (let (var)
> ...)
>
> instead of
> (let ((var))
> ...)
These are equivalent (and not useless).
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-03-06 13:39 ` Michael Heerdegen
@ 2016-03-06 14:09 ` Marcin Borkowski
2016-03-06 14:22 ` Michael Heerdegen
0 siblings, 1 reply; 22+ messages in thread
From: Marcin Borkowski @ 2016-03-06 14:09 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
On 2016-03-06, at 14:39, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> (defun create-stopwatch ()
>> "Return a closure which returns time (in seconds) since its
>> last invocation every time it is called."
>> (let (last-invocation-time (current-time))
>> (lambda ()
>> (prog1
>> (time-to-seconds (time-subtract (current-time) last-invocation-time))
>> (setq last-invocation-time (current-time))))))
>>
>> I don't claim it to be better, but I noticed a strange phenomenon. When
>> I invoke the "stopwatch object" (closure, in fact) for the first time,
>> I get negative result. Why is that so?
>
> Eehm, eh...looks like your let bindings are not what you intended...
Yeah, I hit C-c C-c too early...
> Ask the byte compiler!
The problem is, it didn't complain!
> Regards,
>
> Michael.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Making sure I'm not checking email (or doing other things) too often
2016-03-06 14:09 ` Marcin Borkowski
@ 2016-03-06 14:22 ` Michael Heerdegen
0 siblings, 0 replies; 22+ messages in thread
From: Michael Heerdegen @ 2016-03-06 14:22 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: help-gnu-emacs
Marcin Borkowski <mbork@mbork.pl> writes:
> > Ask the byte compiler!
>
> The problem is, it didn't complain!
It does for me, it says that `current-time' is an unused variable. And
that's the maximum the compiler can do.
Did your file have a correct "lexical-binding: t" declaration (for
dynamical binding, the compiler can't know whether `current-time' is
really unused) ?
Michael.
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2016-03-06 14:22 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-14 21:05 Making sure I'm not checking email (or doing other things) too often Marcin Borkowski
2016-02-15 1:29 ` Emanuel Berg
2016-02-15 15:21 ` Marcin Borkowski
2016-02-15 16:32 ` tomas
2016-02-16 0:48 ` Emanuel Berg
2016-02-16 7:38 ` tomas
2016-02-17 2:38 ` Emanuel Berg
2016-02-16 0:37 ` Emanuel Berg
[not found] ` <mailman.4745.1455549737.843.help-gnu-emacs@gnu.org>
2016-02-15 21:10 ` Joost Kremers
2016-02-16 0:56 ` Emanuel Berg
2016-02-17 13:42 ` Rusi
2016-02-18 0:24 ` Emanuel Berg
2016-02-15 14:40 ` Michael Heerdegen
2016-02-15 14:58 ` Marcin Borkowski
2016-02-15 15:08 ` Michael Heerdegen
2016-02-15 15:18 ` Marcin Borkowski
2016-03-06 13:26 ` Marcin Borkowski
2016-03-06 13:36 ` Marcin Borkowski
2016-03-06 13:59 ` Michael Heerdegen
2016-03-06 13:39 ` Michael Heerdegen
2016-03-06 14:09 ` Marcin Borkowski
2016-03-06 14:22 ` Michael Heerdegen
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).