Mac OS X Emacs Does Not Highlight Comments Correctly - emacs

I'm pretty old school sometimes and I like working with Emacs in my terminal. (I work with IDEs all the time. But sometimes, when in the privacy of my own home, I just like a text editor a terminal and a beer)
However, the default Emacs that comes with OS X does not seem to highlight the comments in font-lock-mode. I've seen this behavior in both Python and C mode.
I've already searched some forums and I found one post where the person was having the same problem as me:
http://forums.macosxhints.com/showthread.php?p=512361
Is is there any way to fix this problem?

I had this exact same problem. The solution is to change the color used for the comment face as follows:
(set-face-foreground 'font-lock-comment-face "red")
Or, if you only want to do this for certain modes:
;;; Only do this for the common C mode (C, C++, Objective-C)
(add-hook 'c-mode-common-hook #'(lambda () (set-face-foreground 'font-lock-comment-face "red")))
For more information on faces, see http://www.gnu.org/software/emacs/manual/html_node/emacs/Faces.html.

I'm not sure exactly how to fix it, but I'm fairly certain there's something you can put in the .emacs file. In fact, I think I've done that before. I'll look for my file and let you know what I can find.
I'll try and get you my .emacs file when I get home from work tonight.
[edit] I've looked and looked, and can't find a .emacs file on either system that I use, and on my OS X install (Leopard default), it looks like it does it correctly by default. I did some research here, and it looks like the default installations no longer use .emacs files, because there's folks like me that mess around with them and break things, and they got tired of having to help us fix it. But, there is a set of menus that will let you tweak things. Start by typing "M-x customize RET", where M is the meta character (on my OSX install, this is the esc key. Don't hold it down, just type it like a regular character. That'll get you into a menu of stuff you can change. I didn't poke around too much, so I'm not sure where in the menu you'll find what you're looking for. Sorry I couldn't be more help.

In my experience this is usually related to a unpaired quote (single-, double-, or otherwise) somewhere in an existing comment.
Hunt those occurences down and eradicate them in your source code (or if you are more ambitious, see if you can update the fontlock code in your major modes' emacs source code)
When I have encountered this in editting Perl in emacs, I often switch major modes to cperl-mode as it typically handles parsing the perl better than the default perl-mode.

Related

TODO Tool window in Emacs?

I'm looking for a functionality like:
the TODO tool window of IntelliJ IDEA (see https://www.jetbrains.com/help/idea/todo-example.html) or
the Tasks list of Eclipse (see https://dzone.com/articles/to-do-lists-with-eclipse-tasks-view).
And I'd like that window to be opened automatically (if not empty) when opening any file or, at least, to have a message in the echo area stating that there are some TODO/FIXME items in the file I'm currently opening.
So far, I did not find any matching package, only things (like fic-ext-mode) that would highlight TODO and FIXME in comments for common programming languages, but no more.
Is there something else, closer to what I'm looking for? I'm certainly not the first one looking for such a feature in our favorite editor ;-)
hl-todo has hl-todo-occur, which opens an occur buffer of all the keywords it's configured to highlight in the current buffer. You should be able to add it to a major mode hook like so:
(add-hook 'prog-mode-hook #'hl-todo-occur)
But this doesn't work. I think it's because hl-todo-mode is activated in prog-mode-hook, and it isn't ready yet. I don't have time to track this down right now.
If you use magit, I just saw a new package magit-todos. I haven't tried it, but it looks pretty nice.
Not aware of an existing module. It would be nice to have one. If you can write, use elisp and M-x Highlight-regexp and M-x occur and then write a hook to open occur window when you open a file. May be a macro will do for this too. You can do more with elisp, such as make occur window renamed as TODO-window and parse the entries to convert into org-mode table to sort entries while preserving the clicking etc.

Emacs ECB methods window not updating

So I do have Emacs 24.3.1 installed, and from 24 onwards it comes with CEDET. I installed ECB through list-packages and everything seems to work - except methods window refreshing.
When I open a file, all methods are displayed and I can jump to them no problem. But the issue is that they never refresh without restarting Emacs. I have experimented with almost every related variable I could find and nothing works.
I am desperately looking for solution, sice it pretty much nullifies methods window usability when I'm expanding the project.
I have these variables added, no Emacs errors, but it still won't refresh - neither after saving, nor after some idle time.
(setq auto-update-methods-after-save 1)
(global-semantic-idle-scheduler-mode 1)
(global-semanticdb-minor-mode 1)
I am new to this, so I may be missing some obvious solution. Could anyone help me? I can provide any configuration file or info you'll need.
EDIT: Of course tried C-c . r , no results.
I've just had same problem. The methods list got updated after I do:
1) revert-buffer
2) ecb-rebuild-methods-buffer (C-c . r)
The fact that just p.2 is not enough seems to be a bug though.

Removing DocView Welcome Page on Emacs

Emacs 23 can view PDF files inside the editor which is great. However it also shows a welcome page, for every PDF page, like this:
How can I remove this welcome page? I understand Emacs is doing some processing for the PDF page, and it probably does not want the user to try to open the file over and over again while it is doing that, but I'd prefer and hourglass instead of a whole page.
I tried setting doc-view-conversion-refresh-interval to nil BTW, it didnt work.
I am on GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.4).
Thanks,
WRT your answer, it sounds like you either edited the original file, or made a replacement copy of that entire library.
The first way will be lost when you update Emacs. The second way means you won't get any improvements to that library when you update Emacs. Neither is a very good option.
Instead you can tell Emacs that if and when it loads the original library, it should re-define that one function at that time.
This minimises the potential problems associated with upgrades, and does not require you to load the library unconditionally in your .emacs (which would increase your start-up time unnecessarily for sessions where you didn't load any PDFs).
(eval-after-load 'doc-view
'(defun doc-view-buffer-message ()
;; your definition here
))
I think you need to press C-c C-c
I found doc-view.el source for Emacs 23, and I removed the message from doc-view-buffer-message function. So now when PDF is loaded an empty page is shown which is less confusing, welcome page made it look like the PDF was loaded.
After the changes I did byte-compile-file on the el file, and at the end of my .emacs I load this overriding the original doc-view.

How can I make emacs stop loading viper-mode?

I'm developing a mode for Emacs, and everytime I switch to its buffer, viper gets turned on. I've modified viper-mode to trace where viper-mode is being called, and surprisingly set-viper-state-in-major-mode is called by running the viper-post-command-hooks, set to nil. Any idea of what is going on?
Thanks!
EDIT: For the benefit of all beings, here is what I found out: as instructed by Trey, I started emacs with -Q and manually loaded both viper and my package. As I could reproduce the bug, the problem was on one of these packages. After line-by-line filtering, I discovered that the innoquous-looking (kill-all-local-variables) was causing the problem.
There's something in initialization that's causing it.
First try starting without your .emacs emacs -q. If the problem persists, then the trigger is in the site-start.el. So, talk to whomever installed Emacs and get them to remove the customizations there. You can also always use the -Q startup option to avoid loading the site-start.el.
If the problem isn't in site-start.el, and you don't think it's in your .emacs, it might be in a custom default.el file, which you can prevent from being loaded by adding:
(setq inhibit-default-init t)
to your .emacs.
If you still have a problem, then I'm 99% sure it's in your .emacs.
To be 100% sure, try emacs -Q, which runs Emacs with no customizations. If the problem persists, download and install your own Emacs b/c you surely can't trust the installation you're using.
So, now if you're convinced it's in your .emacs, start cutting out parts of your .emacs, or introduce an error in your .emacs with (error "frog"), and progressively rule out which portions of your .emacs are causing the problem.
g'luck
The function kill-all-local-variables will run all functions added to change-major-mode-hook, this is a common way for global minor modes to initialize themselves. For example, global font lock and global cwarn mode use this.
I haven't used viper myself, but chances are that it use this mechanism. Of course, you still would have had to enable it in your init file, somehow, so if you simply would stop doing this, it would solve your problem as well.
Try commenting out any references to viper mode in your .emacs. I don't get sent into viper mode, unless I start playing around with viper mode before I eval your new mode.
Maybe there's more being done with this statement than you think:
(use-local-map ecoli-map)
Try to change some of your binds in your map. eg. j to C-j and k to C-k.
Maybe emacs is getting confused?
Try removing your ~/.viper config file, and also check your .custom.el for settings that might kick viper into action in your major mode (or globally).

Better control over Emacs windows

I spend a lot of my time in emacs, and for the most part it's wonderful. But one thing really drives me nuts when I'm deep in it, and that's control over which window various new buffers are opened in. When I do find-file, it always opens in the current window, and this is what I like. But tons of other modes like to split my windows for me, change the layout, and do various other things that annoy me. For example running M-x manual-entry seems to have no rhyme or reason about where it opens the manpage, and various org-mode commands do the same thing, closing windows I want to keep open, etc. I don't like having to redo my layout everytime I want to look at my org agenda or open a manpage.
In short, is there anyway to globally control which windows are used for modes that want to open in a window other than the current one? Can I direct them more easily? Or will I have to hack each mode to act the way I want it to?
Try Winner mode:
http://www.emacswiki.org/emacs/WinnerMode
It provides an undo/redo for changes to the window configuration.
This question has always bugged me too. I found this:
http://www.gnu.org/software/emacs/elisp/html_node/Choosing-Window.html
It looks like you can use (setf pop-up-frames t) to make stuff show up in a new frame.
Also, it looks like you can use display-buffer-function to override the display function (how buffers are chosen.) Of course, you'd have to be good at elisp.