GNU Emacs: Using helm-unicode; changing the font and font size only for helm-unicode; etc. |
Sunday, January 8th, 2017 23:37:45 GMT |
I recently figured out that in GNU Emacs, I was using the helm-unicode extension wrong.
After installing that, I mistakenly assumed that the key sequence Ctrl-x 8 Return (or,
Finally, I figured out that
If you don't have the "Symbola" Unicode font, you can change "Symbola" to another font name. Or, you can download Symbola from this page:
The problem with using that code is, it can sometimes make GNU Emacs very slow - for example, if you do the key sequence
I suggest pasting that code into your *scratch* buffer. Then, put your cursor (or "point" as it's called in GNU Emacs jargon) at the end of the "print-elements-of-list" function definition and do the key sequence
Then, to actually output the list into whatever buffer you're running this in, put your cursor at the end of the last line and do the key sequence C-x 8 RET
for short) was automatically now using helm-unicode. Then I was confused that the list of Unicode characters only had names and not the actual characters.
C-x 8 RET
was only running the command (insert-char)
, not (helm-unicode)
. (To find out what command is assigned to a key sequence or keychord, you can type C-h k
, then after the prompt "Describe key (or click menu item):" appears in the minibuffer, type the key, key chord or key sequence you're curious about.)
To make C-x 8 RET
run (helm-unicode)
instead, I had to run this command (and I also added it to my GNU Emacs preferences):
Another useful thing to add is this code to make the font larger only for helm-unicode searches. It's code I slightly modified, most of which I originally found on this page:
http://users.teilar.gr/~g1951d/
Also, here's some code I found somewhere which will make GNU Emacs display Unicode in any buffer:
C-h h
to look at the "HELLO" file included with GNU Emacs, which shows translations of the word "hello" in many different languages.
If you want to output the entire Unicode character list as browseable, editable text in a buffer, try this. A slightly modified version of code I found on this page:
C-x C-e
.
C-u C-x C-e
.
▲ Top ▼ Bottom △ TOC ↓ Down Up ↑
Partway fixed a really bad glitch in multifiles-apmod.el |
Sunday, January 10th, 2016 22:18:04 GMT |
Today, I discovered and partway fixed a really bad glitch in multifiles-apmod.el, and updated multifiles-apmod.el to version 2.0.
This glitch is terrible enough for me to post this whole new blog post just to draw attention to it and encourage people to update to the safer - though still only partway fixed - version 2.0.
I don't know if I'll be able to fix it completely in the near future, and there could always be other problems that I don't even know about yet, so, please be careful.
The glitch is avoidable if you don't make any of your embedded buffers or files read-only - but ideally I'd like to somehow make it impossible to run into this glitch at all.
This has been partly fixed by making it so read-only buffers are blocked from being added to a multifile when a multifile is first being built.
However, I don't yet know how to make it impossible to make the embedded buffers read-only after they've been added to a multifile. So, unfortunately, it is still possible to run into this horrible glitch accidentally, such as by going to the original buffer of an embedded buffer, and clicking the asterisk at the left of your modeline which toggles whether the buffer is writable or read-only.
And to make matters worse, because the mirroring of ALL embedded files in ALL multifiles gets messed up by this glitch, Emacs probably won't even ask you at shutdown if you want to save even the writable embedded files you edited!
So, please be careful. If you do run into this horrible problem, then, to save your data, you can copy and paste the entire contents of your multifile into another buffer and save that buffer, which will create one large combined file. Sorry, I don't know of an easy way to merge the changes in that large combined file back into your separate files.
Quoted from the Readme:
This version partway fixes a REALLY bad glitch I discovered today. The glitch is caused by editing read-only buffers in a multifile, which somehow messes up the mirroring in ALL multifiles (even multifiles you weren't editing and which don't contain read-only buffers), and makes it impossible for ALL multifiles to save their embedded files.
▲ Top ▼ Bottom △ TOC ↓ Down Up ↑
Emacs Add-On: multifiles-apmod.el |
Tuesday, December 15th, 2015 21:12:56 GMT |
Add-On |
I finally managed to make most of the modifications and additions I wanted to make to Magnar Sveen's incredibly useful "multifiles.el" add-on for GNU Emacs.
Here's multifiles-apmod.el on GitHub:
(Addition, Jan. 10, 2016, 4:52 PM: Updated to Version 2.0, which partway fixes a really bad glitch I discovered today.)
Addition, 12/21/2015, 2:07 AM EST: Recently figured out and uploaded a slightly better solution to the slowness of my large PHP multifiles - perly-php-mode.el, which is simply perl-mode.el slightly modified to masquerade as php-mode. 12/24/2015, 5:24 AM EST: Released version 1.2.)
Now, my difficulty remembering which files I put whatever things into won't get in my way as much anymore. If I space out and forget something, I can just daydreamily float around until something scrolls by which reminds me. Much more effortless and relaxing than having to click from tab to tab, or try to remember what I named things so I can do searches.
And searching is easier too, with everything apparently being in the same file.
But, I think multifiles-apmod.el and GNU Emacs will already suffice to make it tremendously easier and more comfortable for me to get most any of my projects done.
Hopefully others will find it useful too. Perhaps even non-programmers might like it, such as anyone who likes Scrivener's Scrivenings mode.
I still haven't 100% perfected my Emacs setup, but, it's already mostly more comfortable for me to use than even my previous favorite editors, Notepad++ and Geany.
So, I think this might be the beginning of a golden age or renaissance for my programming hobby (or maybe almost career).
Tremendous thanks to everyone who made this possible!
It's so nice finally being able to mindlessly scroll around my entire projects (at least the smaller projects) all in one page. I don't have to do searches nor even click tabs to get around.
Someday, I'd like to have an even more bizarre code editor with a concept map layout similar to VUE, or something like Code Bubbles (which I still haven't tried yet but which seems really cool, from what I've read/seen).
So, I guess now I can finally return to working on my usual projects again.
▲ Top ▼ Bottom △ TOC ↓ Down Up ↑
Emacs Lisp code: Mouse-Clickable Search Results in Helm (with some glitches) |
Friday, December 4th, 2015 14:24:50 GMT |
Helm is one of the most useful add-ons I've found for the GNU Emacs operating system - uh, I mean, text editor - so far.
Helm makes it tremendously easier to find all sorts of things such as files, buffers, function names, variable names, and text within files or buffers. In many Helm modes, you can just type a few letters, and Helm will narrow down your search and instantly display updated results.
Helm also gives you a way to browse and search your "imenu", which is where php-mode puts a list of functions defined in the PHP file (or multifile!) you're currently looking at.
And you can easily go to any of those functions by selecting its name in the Helm search results and pressing Return or Ctrl-j. Or, thanks to the below code, by double-clicking or right-clicking on any item in the Helm search results with your mouse.
That seemed like the sort of thing someone probably already wrote an add-on to fix, so I searched the web, and soon found this post on Reddit:
To my delight, that code worked quite well out of the box. But, it globally overwrote my preferred mouse click settings, so, I had to figure out how to make some custom mouse click settings that would only be in effect while Helm was running.
Even though my final result wasn't very much code in the end, it still took me hours and lots of trial and error to figure out how to do it, and I wasn't sure I ever would figure it out. But somehow, I managed to cobble together the below code, which uses most of the code provided in the abovementioned Reddit post, plus some other code to create a custom minor mode which is supposed to only run when Helm is active.
Since I'm such an Emacs newbie, it would have taken quite a lot longer if I hadn't been able to stand on the shoulders of numerous giants, such as the author of the code in the abovementioned Reddit post, and all the authors of all the web pages and documentation I read that helped me figure out how to do this.
Thanks to everyone!
But, it still makes Emacs and Helm more cozy and intuitive to use.
The below code only requires the Helm add-on, and can just be copied and pasted into your .emacs settings file, probably somewhere after the place in your settings code where you loaded Helm.
While trying to debug the above, I figured out that one glitch I had actually wasn't caused by the above.
I figured out that the Purpose add-on interferes with Helm by somehow making Helm open help text in the wrong window pane - usually Helm's own window pane - which accidentally kills Helm sessions. The only solution to that I found so far was to turn off the Purpose add-on.
By the way, I actually often make small, usually unmentioned edits to my blog posts after I publish them - but this edit seems important to point out because the lack of those backslashes probably could have stopped the code from working properly.
I guess the vanishing backslash problem is another thing I need to fix in my WordsPlatz blog software. WordsPlatz has served me well with scarcely any changes since 2009, but, I actually am still interested in updating it and improving it.
By default, the Helm add-on has no mouse capabilities at all. So, I kept accidentally trying to click Helm results, resulting in nothing happening.
I still haven't figured out how to make the below code not get confused by mouse-wheel scrolling, and there could be other glitches too.
I'm using GNU Emacs 24.5.1. And I'm not sure what version of the Helm add-on - all I know is I downloaded it on Nov. 13, 2015 at 6:22:26 AM EST from GitHub.
Edit, 2:47/3:08 PM EST. Added some missing backslashes to the above code. And changed some wording.
▲ Top ▼ Bottom △ TOC ↓ Down Up ↑
Emacs Lisp code: Right-Click to Highlight and Select Name - Sort of Like Notepad++ |
Wednesday, December 2nd, 2015 06:47:22 GMT |
The text (and code) editor Notepad++ has a nice feature where all you have to do to temporarily highlight a name (such as a variable name, function name, command name, or other words) everywhere is double-click on it.
Emacs doesn't do that out of the box, and I didn't find a way to make Emacs behave exactly like Notepad++.
But, I like the below behavior more in some ways anyway.
Sorry, I don't know how to get rid of the "Wrong type argument: syntax-table-p, nil" error message. But it seems to work fine despite that error message.
And the above code does interfere with whatever right-clicking is supposed to do by default. But the original default behavior of right-click was rather dangerous and useless-seeming - unexpectedly selecting blocks of text and often deleting any text that was already selected - so I'm glad to be rid of that, whatever that was.
The highlighting persists forever until you either right-click on the name again, or run the (highlight-symbol) function in some other way, such as clicking on the name and pressing F3 - the key I've bound to (highlight-symbol).
Right-clicking not only highlights the name, but also selects (or "marks", in Emacs jargon) some, most, or all of the name under your cursor (or "point", in Emacs jargon).
If you right-clicked anything other than a dash or underscore, the only thing that gets selected is the word you clicked. So, you can easily select individual words in a function or variable name with dashes or underscores in it - something I never figured out how to do in Notepad++.
However, in Emacs, I don't know how to make it possible to so easily persistently highlight (as opposed to select) just individual words, because highlight-symbol.el pays no attention to what text you have or haven't selected - it just highlights the entire name it detects where your cursor (point) is.
But, doing a search while using the code from this previous blog post - Emacs Lisp code: Easily Search for Text You've Selected - will let you easily and case-insensitively put a temporary highlight on any arbitrary currently-selected text.
I'm using GNU Emacs 24.5.1. The below requires three add-ons:
Here's all the code I had to add to my .emacs settings file:
After adding the above code and add-ons to your Emacs, it should be possible to right-click on a name to highlight that name everywhere persistently.
If you right-clicked on a dash or underscore in the name, the entire (or almost entire) name gets selected. Excluding any dollar signs at the beginning, to make it easier to select the names of PHP variables without their $ prefix. (But if you ever actually want to also select the dollar sign, a normal left double-click on a PHP variable name, or an underscore inside it, should accomplish that.)
▲ Top ▼ Bottom △ TOC ↓ Down Up ↑
Emacs Lisp code: Easily Search for Text You've Selected |
Tuesday, December 1st, 2015 13:42:54 GMT |
(Updated at 9:27 AM EST.) I finally ran across a nice, slick way to be able to immediately search for the text I've selected in Emacs.
Most good text editors have something like that feature by default - but not Emacs, which was another maddening nuisance for me until today.
I found two solutions in this StackOverflow page. I prefer this solution, reproduced below.
I prefer the above because it even makes backward searching with C-r work right, not just forward searching with C-s, and acts normal when you search without selecting any text.
Prior to finding the above solutions in this StackOverflow post, the closest thing I had to a solution was the excellent highlight-symbol.el add-on.
Th highlight-symbol.el add-on is still very useful to me. The way I have it set up, I can press a single key - F4 - to search for whatever word (or function name, or whatever - even if it contains dashes and/or underscores) the point is resting inside. I can press Ctrl-F3 to easily replace that text. And I can press F3 to highlight that text throughout a buffer.
But, the highlight-symbol.el add-on doesn't provide a way to search for any arbitrary selected text, since that add-on doesn't require you to select text, nor pay any attention if you do select some text.
I'm still looking for a way to easily replace selected text, and will update this post if/when I find a way.
The original solution I tried only fixes forward searching, and erroneously selects blocks of text if you try to search without selecting any text. The second "search-selection" function from this StackOverflow post, reproduced below, along with the commands I added to my .emacs file to change the keychord C-s to make it use the "search-selection" function instead of "isearch-forward":
▲ Top ▼ Bottom △ TOC ↓ Down Up ↑
Emacs: How to have tabbing and indentation similar to a more typical text editor |
Monday, November 16th, 2015 05:34:36 GMT |
The Emacs editor has a bunch of default behaviors that were driving me crazy:
(Plus other, less insanity-inducing problems - but those aren't solved in this post.)
And also the automatic indentation in php-mode.
But, I'm pretty new to Emacs, so, there might be side effects or other problems with the below solution I'm not yet aware of. Comments are welcome!
Thanks to everyone on the web who posted useful info and/or code which enabled me to cobble together my current favorite solution.
I put the below code in my ".emacs" settings file. I'm using Emacs 24.5.1.
In php-mode.el, I changed every instance of
I don't yet know of a less invasive way to fix it than that. But, that worked.
And use this line instead, with "lighter" set to "nil". (It's included in the box of code above, so you can just uncomment it.)
Finally, I figured out how to fix all of that, and make Emacs' tabbing and auto-indenting be more like a typical text editor.
The only Emacs add-on the below code requires is regtab.el, which makes it possible to indent either one line or entire highlighted regions by pressing tab, and un-indent them by pressing shift-tab.
I had some trouble figuring out how to make php-mode stop doing automatic indent. So, finally, I just resorted to the brute force method of editing php-mode.el's source code.
indent-tabs-mode nil
to indent-tabs-mode t
, and every instance of tab-width 4
to tab-width 7
. (But you can use whatever tab-width number you like).
To stop regtab.el from displaying the text "regtab" in your modeline, you can comment out these lines in regtab.el:
(define-minor-mode regtab-mode "Regular Tabs Minor Mode"
:lighter " regtab" :keymap regtab-mode-map)
▲ Top ▼ Bottom △ TOC ↓ Down Up ↑
Emacs Lisp code: Get Rid of 100-Item Limit on Lists in Helm |
Saturday, November 14th, 2015 15:44:27 GMT |
Code Snippet |
I never before had to fiddle so much with an editor to make it comfortable to use - but, it seems to be paying off, since the idea of sticking with Emacs is starting to seem not only plausible, but appealing. Perhaps I'll be able to return to my usual projects sometime in the next few weeks.
I've been downloading lots of different Emacs add-ons - many of them listed in this section of my GitHub account.
In my ".emacs" settings file, I have this line after the stuff which starts Helm:
That line slows things down a bit, but at least it gets rid of the 100-item limit on the length of lists in Helm.
The add-on Helm makes it much easier to access and list various useful things, such as Emacs' fortunately copious documentation of things like Emacs Lisp functions and variables.
Emacs Lisp code: Insert a NoteCase-like Date/Time with F5 |
Saturday, November 14th, 2015 15:16:18 GMT |
Code Snippet |
The below Emacs Lisp code, which simply inserts a date/time like "2015-11-14 10:01:14" when you press F5, was a slight modification of code I found at this StackOverflow page:
I used "defcustom" and "setq" instead of "defvar" alone because of tips from this page from ErgoEmacs.org: