Closed mankoff closed 11 years ago
It should be possible. Can you show me the regular expressions you use in your configuration?
It appears I made a mistake. My pretty-ification was coming from pretty-mode, not pretty-symbols-mode. I've tried to switch to your (pretty-symbols-mode). Seems like a somewhat more 'official' mode, has a website not just a pastebin, has the goal of being the authoritative prettification source, etc. But I have not had much luck.
I am having trouble customizing this mode to even show the Delta symbol and all the other math symbols that exist in pretty-mode by default. So I do not yet have a regex to show you...
Since I'm having trouble adding new symbols, I tried just changing an existing symbol. Oddly, I cannot even do this. If I change (?∧ logical "&&" (,@c-like))
to (?x logical "&&" (,@c-like))
(show an x
instead of the ∧
), even that does not work, and the ∧
continues to appear. I restart emacs between changes, and make sure no stale compiled elc files exist.
How have you installed pretty-symbols-mode.el? Are you sure that you don't
have some other version installed (e.g. from elpa) that is overriding the
changes you are making? How are you modifying pretty-symbol-patterns
? Any
changes to this have to be done before running pretty-symbols-mode
.
The following works for me:
?λ
to ?x
.
Evaluate the pretty-symbol-patterns form (C-M-x
).† This isn't a good way to do customisations so don't save your changes; instead you'll want to add something to your init file that appends entries to the pretty-symbols-patterns list. But these instructions will prove whether or not pretty-symbols-mode works at all.
I have installed pretty-symbols-mode via elpa, but that is the only one:
~/.emacs.d [master▶] $ find . -name "pretty*"
./elpa/pretty-symbols-mode-20130819.807
./elpa/pretty-symbols-mode-20130819.807/pretty-symbols-mode-autoloads.el
./elpa/pretty-symbols-mode-20130819.807/pretty-symbols-mode-pkg.el
./elpa/pretty-symbols-mode-20130819.807/pretty-symbols-mode.el
./elpa/pretty-symbols-mode-readme.txt
./pretty-mode.el.no
~/.emacs.d [master▶] $
I try to load it with the following code, but it does not seem to auto-load.
(setq pretty-symbol-categories '(lambda relational logical))
(add-hook 'prog-mode 'pretty-symbols-mode)
I thought all programming modes are derived from prog-mode. It also doesn't auto-load if I (add-hook 'python-mode 'pretty-symbols-mode)
I edit ~/.emacs.d/elpa/pretty-symbols-mode-20130819.807/pretty-symbols-mode.el
even though I know I shouldn't be editing the source. I don't evaluate the pattern, but load a new emacs session and type "lambda" and see the lambda symbol, not "x".
Yes it certainly seems like I'm loading a different pretty-symbols-mode, but if I do M-x apropros
and search for "pretty-symbols-mode" and look at the source, it is the edited file.
Very confusing. Thanks for helping. I'm not really a lisp hacker. Sometimes I can code some functions and customize packages to do what I want, but other times simple bugs catch me like whatever this is.
As for customizing the pretty-symbols-patterns
list, I see that is the recommended way to customize things as documented in the code, but I did not see a simple example of adding a symbol that I could follow...
Ok scratch the above. I copied pretty-symbols-mode.el
to ~/.emacs.d, deleted the elpa version, and now customizations do work correctly.
(add-hook 'python-mode 'pretty-symbols-mode)
That should be 'python-mode-hook
. Sorry! I'll fix the documentation in pretty-symbols-mode.el.
Or 'prog-mode-hook
, etc.
Heheh, the documentation had already been fixed 3 weeks ago, I had forgotten. See 1f9ca479.
OK, if you've proved that the mode is working, I recommend you delete the version in ~/.emacs.d, reinstall the elpa version, and close this issue.
I'm not a lisp expert either but to add to pretty-symbol-patterns you'll need something like this in your init file (I haven't tested it):
(add-to-list 'pretty-symbol-patterns '(?Δ ...))
While visiting an elisp file use M-x info-lookup-symbol RET add-to-list RET
for documentation.
Then after restarting Emacs use M-x describe-variable
to check that
it contains what you expect. If you add your symbols under a new category
name remember to add that to pretty-symbol-categories
too.
OK. Thanks for the help so far. I now have it loading if I add an auto-load statement:
(autoload 'pretty-symbols-mode "pretty-symbols-mode" nil t)
(setq pretty-symbol-categories '(λ relational logical))
(add-hook 'prog-mode-hook 'pretty-symbols-mode)
And I can customize symbols! And in your mode, by default, Delta_z turns into Δ_z which is nice. Pretty-mode did not support this behavior.
A few more questions:
pretty-symbols-patterns
list without editing the source?pretty-symbol-categories
and then assign all new symbols to my custom category? Or should I fork, edit the source to add a "greek" and "baseline" (for superscript / subscripts), "math", etc. and then issue a pull? I'm a bit surprised there are not more forks considering the awesomeness of pretty symbols in emacs when coding...Oh. Ok. Your reply showed up while I was writing that. That seems to answer my first question, the most important one. Thank you!
I'd like to add all the math symbols that I had in pretty-mode, the superscripts, etc. How is this best done? In my external custom file should I simply add "custom" to the pretty-symbol-categories and then assign all new symbols to my custom category? Or should I fork, edit the source to add a "greek" and "baseline" (for superscript / subscripts), "math", etc. and then issue a pull? I'm a bit surprised there are not more forks considering the awesomeness of pretty symbols in emacs when coding...
It's up to you. I'll be happy to receive pull requests but before you submit the pull request please use the symbols yourself for a few weeks to make sure that the regexes aren't overly broad.
The original question is not of much import, as Delta_z looks quite good, but if you could provide a hint how to do superscript and subscript I would be grateful. I think it is complex since the "?" match appears to only work with single characters.
I don't know. :-(
I've tried but not succeeded in getting hybrid symbols to work. I can get Delta to turn into the Delta symbol, but would like more than this. For example, Delta_z would look nicest if Delta symbol and then z subscript, but would still look nice even if it were just Delta symbol and then "_z". Is this possible with this mode?