-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a common way to avoid recursion #45
Conversation
If this is merged, don't forget to document it as it is a hack (see the discussion on the referenced issue above and the documentation about minor mode conventions). Prefere to introduce a new variable |
I disagree with @syl20bnr. This is not a hack but what you are supposed to do - it does not have to be documented. Adding |
I fully disagree with this. See my comment on the hydra issue and on the abo-abo PR as well. Using |
I think "fully" is a bit of an exaggeration - we now both seem to agree that this package should allow the use of a let-binding to inhibit modified behavior. We only disagree on whether it is necessary to add an additional variable for that and to document this. |
There is already an additional intermediate variable in the proposed PR Le mercredi 29 avril 2015, Jonas Bernoulli notifications@github.com a
-syl20bnr- |
This discussion is a bit like using Le mercredi 29 avril 2015, Jonas Bernoulli notifications@github.com a
-syl20bnr- |
I really don't care what variable I have to let-bind as long as there is one that is respected by the advice.
Like @abo-abo, I am an experienced elisp coder, and I too am a bit offended your need to throw in such qualifiers. So using an additional variable might or might not have semantic advantages. What is important though is that this mode provides some way to let-bind it out of effect. But because semantic disagreements were hanging in the air, just nothing happened. To me it is clear that let-binding a mode variable does not turn of a mode, but just suppresses it's effect temporarily (provided the mode has arranged for that). That's because I have seen it done like this many times before. For other people who have not seen it done that way this might be a bit surprising, so by all means use an |
Use a common way to avoid recursion
Thanks @vkazanov , merged. |
@thierryvolpiatto I don't understand why you merged this PR and not #46 instead. #46 is a better change and only needed the replacement of the variable for an inhibit variable which simplified the implementation and provided a better semantic while being cleaner. I really need @roman to tell us what he want us to do on this. I did not merged #45 or #46 because I wanted him to raise his voice. @roman what is your opinion on this ? |
@tarsius sorry I did not mean to be offending at all. Did I say such a thing when you tell me to not fork and contribute upstream and suppose that I fork all over the place in Spacemacs ? Nope but I certainly could. But I don't think it bring anything meaningful to say such a thing. What I meant by experienced elisp coder is that we do care about semantic and I know you are an experienced coder, a lot more than me, so sorry if you missinterpreted but it was just an argument for better semantic, nothing more. I fully :-) agree that modifying temporarily
Sorry for the typo, I'm on my phone :-) |
Sylvain Benner notifications@github.com writes:
#46 is unclean and contain many unrelated and unwanted changes.
It is not, it is an unfinished work. Thierry |
It may be unfinished, but it's better to advise a single function that's actually related to windows rather than just burn resources in Arguably, |
@thierryvolpiatto Can you elaborate on this ? Le jeudi 30 avril 2015, Thierry Volpiatto notifications@github.com a
-syl20bnr- |
Oleh Krehel notifications@github.com writes:
Probably, I don't remember why I was using post-command-hook so I Thanks. Thierry |
|
@@ -94,15 +95,13 @@ will not cause the window to be resized to the golden ratio." | |||
(loop for fun in golden-ratio-inhibit-functions | |||
thereis (funcall fun)))) | |||
(let ((dims (golden-ratio--dimensions)) | |||
(golden-p (if golden-ratio-mode 1 -1))) | |||
(golden-ratio-mode nil)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between using nil and -1, and any particular reason this was moved to the let statement and not keep it where it was before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roman Gonzalez notifications@github.com writes:
In golden-ratio.el:
@@ -94,15 +95,13 @@ will not cause the window to be resized to the golden ratio."
(loop for fun in golden-ratio-inhibit-functions
thereis (funcall fun))))
(let ((dims (golden-ratio--dimensions))
(golden-p (if golden-ratio-mode 1 -1)))
(golden-ratio-mode nil))
What is the difference between using nil and -1, and any particular
reason this was moved to the let statement and not keep it where it
was before?
IIUC they have problems with the hydra package and doing so instead
of disabling the whole mode avoid recursion.
I can't give you more details because I don't use the hydra package.
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
@syl20bnr personally I like this PR better because it is more concise, #46 is a more involved change which requires to be separated into multiple PRs (not suggesting that changes are not a good improvement in readability though) as @thierryvolpiatto states, something like #46 can be merged on top of this PR once it is formalized. Cheers. |
@roman That's fine about #46 but it put some noise on my point which is about bypassing Setting the variable So I proposed to create a variable I think semantic is very important and it can greatly improve the code readability, Another point about readability, in a (let (golden-ratio-mode) ...) Because in Emacs (let ((inhibit-golden-ratio t)) ...) Moreover as we can find occurrences of this hack in Emacs sources we can also find occurrences of What do you think about it ? |
The example above is not fair because it can be written: (let ((golden-ratio-mode nil)) ...) Which is better for readability, but this does not invalidate the points above. |
@syl20bnr My neither. Sorry if it came across that way. |
This patch allows for comfortable temporary disabling of the
golden-ratio
function, while still avoiding recursion:(let (golden-ratio-mode nil) do-something-with-window-here)
. Otherwise, it works as intended.It turned out that hydra's (see https://github.com/abo-abo/hydra) uses a special echo window, and using a usual way to disable a minor mode does not work (see abo-abo/hydra#64 for more details). Actually, the hydra project owner already had three related issues. :-)