-
Notifications
You must be signed in to change notification settings - Fork 14
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
Broken load-theme-buffer-local #5
Comments
Using b4444be seems to work, so I think the issue is that you need to update the MELPA package. |
I had this problem too. It only happened on my windows emacs 24.3.1 and not on my ubuntu 1404 emacs 24.3.1. The problem is emacs 24.3 seems to require all common lisp (cl) functions be prefixed with "cl". This is true for "loop" (now "cl-loop") and "flet" (now "cl-flet"). You used to be able to get away with not prefixing them. If you look in file 'load-theme-buffer-local.el' under the ELPA path (~/.emacs.d/elpa/load-theme-buffer-local-20120702.1336) you'll see it's using "flet" to dynamically define the function "symbol". I just updated this to have 'cl-flet'. Here is what the updated code looks like: ;;;###autoload Don't forget to to c-x c-e against the updated defun so it takes effect, and the to do a 'byte-compile-file' to create the '.elc' file so it take effect when you re-start emacs as well. Now 'load-theme-buffer-local' runs, but unfortunately it is not buffer level. It updates all buffers just like 'load-theme'. Trying to figure that one out now. |
@vt5491 could you provide a pull-request ? |
Hi Vic, Here is where I am currently at with the modified version on my laptop.
However, as previously mentioned, since cl-flet uses lexical binding it means that the override is lost once it leaves the confine of the setting up function ('load-theme-buffer-local'), whereas with flet, which uses dynamic binding, the override was in effect 'all the way down'. So the problem becomes how to override these functions without using flet.
Unfortunately, I could not get around advice working, which perhaps isn't surprising since I'm just learning elisp and aspect oriented programming is generally considered to be a pretty advanced technique in most languages.
I don't know if this is existing behavior, or it's somehow an effect of how I did it. I suppose I could use my Ubuntu as a control, since it doesn't seem to have a problem with 'flet'. In other words, I need to do more testing.
Anyway, if I can work out a way to get it working without requiring another module, I will try to do a ‘pull-request’ at that time. |
I started working on this again. I got defadvice (around advice) now working. This is a lot better than noflet in that it doesn't introduce new dependencies on the module. Here is what my current development version of 'load-theme-buffer-local' looks like. It needs clean up, I still have debug messages in, and I need to remove my initials from the variables etc (convenient during testing so I know what is "mine"), but it does work:
I figure I'll put in an (fboundp 'flet) call and use flet by default if it's available, and only use advice if flet is not available. I also just need to add:
at the end to remove the monkey-patch so 'load-theme' would work in it's standard fashion. I forked a new branch and will commit my changes and do a pull-request at that time. I still need more time to test it etc. I have also previously hooked the 'custom-theme-recalc-face' function as well, although it doesn't seemed to be used, at least when I change themes. I also do no see error messages on the Messages log like before. Wonder if hooking 'custom-theme-recalc-face' is what was causing this? |
I'm now leaning towards using 'noflet' instead of using advice. I read the following from elisp entry on wikipedia (http://en.wikipedia.org/wiki/Emacs_Lisp): Discouraged features[edit] After decades of evolution, some features have become deprecated or replaced, and other features are now supported for Emacs users but their use is not allowed in the Emacs source code itself. defadvice and letf are two examples of the latter, of which Richard Stallman says "it makes for confusion in debugging. (...) Users can use these features -- the only people they might confuse are themselves, (....) However, in our code, we should handle these situations in other ways."[3] Adding new hooks can sometimes provide what's necessary to replace advice.[9] |
use 'noflet' instead of 'flet' to override the functions 'custom-theme-buffer-local-recalc-face' and 'custom-theme-buffer-local-recalc-variable'. In later versions of emacs, 'flet' is reverting to lexical binding instead of dynamic binding, thus the methods are no longer being hooked downsteam. This introduces a dependency on package 'noflet'. I did not update the autoload to automatically require this package. Without this fix, on certain versions of emacs you will get the following message when trying to run 'load-theme-buffer-local': Symbol's function definition is void: symbol
This was originally only only a problem on windows emacs. Recently it just started happening on ubuntu 14.10. It does not happen on Ubuntu 1404, or linux mint 17.0 or 17.1. Anyways, I just wanted it to work on ubuntu, so I just made the easiest change which is to use noflet. Note: I did not update the package manager ('load-theme-buffer-local-autoloads.el') to require 'noflet', as I'm not familiar with that mechanism. Instead of researching it to death, and trying to find the 'best' solution like last time, I just decided to make a quick and dirty fix, as now I'm time constrained and if I don't do it now I'll never do it. The point it is, if you decide to accept the fix, you're going to have to update the package to require noflet. |
This can be closed now. It's simply not happening anymore. It originally only happened only on windows. Anyway, I'm running emacs 25.0 on windows and linux and this is not happening. Not that going to emacs 25 made a difference -- it was working with emacs 24.3 and 24.5. I think it's safe to say this was an environmental issue and not a problem with 'load-theme-buffer-local'. Whatever the environmental issue was it's now gone away. |
ok closing now. |
The issue seems to be back on emacs 28.2. I am getting exactly the same error message. I am on Fedora. |
I was also seeing this issue on Emacs for Mac OSX 28.2, and on Aquamacs. I was able to correct it by following the advice by @vt5491 on #6 (under the "files changed" tab) : after installing noflet, I changed the two lines mentioned on pull request #6 on my load-theme-buffer-local.el and byte-compiled it, then restarted Emacs again. That got me the correct behavior. I'm still working on getting the correct functionality on Aquamacs, though. |
Using load-theme-buffer-local 20120702.1336 from MELPA in emacs 24.3.1:
(load-theme-buffer-local 'theme-name)
Breaks with:
The text was updated successfully, but these errors were encountered: