Function defined in .emacs does not start automatically - emacs

I've just started using Fill Column Indicator for Emacs, which adds a vertical line on editing window to indicate the fill column.
I figured out that turn-on-fci-mode function could trigger the the bar.
I wanted it to start at the time when Emacs starts, so I also included it in the .emacs file.
The changes in the .emacs files are as follows:
(add-to-list 'load-path "~/.emacs.d/custom")
(require 'fill-column-indicator)
(turn-on-fci-mode)
Unfortunately, the line does not come up, even though running the function manually brings up the line.

fci-mode is buffer local. That means you need to turn it on for each buffer individually - setting it in your .emacs will set for one buffer, possibly just the splash screen, and not have any influence on the rest of your buffers.
To turn it on for all buffers, you need to use the following code in .emacs:
(define-globalized-minor-mode global-fci-mode fci-mode (lambda () (fci-mode 1)))
(global-fci-mode 1)

Related

emacs - startup window size changed from default to maximum

I use below code to setup emacs using fullscreen:
(setq initial-frame-alist '( (fullscreen . maximized)))
(setq default-frame-alist '( (fullscreen . fullheight)))
I wish it startup with maximized window, the behavior is almost as expected but the window size firstly with default size, then I can see it changed to maximum size obviously.
How can emacs startup to fullscreen in one step?
Look at the documentation for initial-frame-alist (C-h v initial-frame-alist). In particular, Emacs creates the first frame before reading init.el, so you need to specify these things somewhere other than init.el. Two common ways are to give the --maximized command line option, or to set the X11 resource Emacs.Fullscreen: maximized; either of these are applied before init.el is read and evaluated.
It looks like you're on OS X, which I don't have, and it may be different there.
Update for Emacs 27:
You can set these things in early-init.el, which loads before the GUI starts.

How do I disable line numbers in Helm buffers?

I'm using linum to show line numbers. What I want is to have them enabled by default, but disabled in certain major modes, like eshell, compilation, etc.
This works well, but what I can't figure out is how to disable them in Helm buffers.
There doesn't seem to be a major mode I can hook into
(add-hook 'helm-before-initialize-hook '(lambda () (linum-mode 0))) turns off line numbers globally. Not sure how to disable linum for the current buffer only, since Helm buffers usually appear alongside another one
Tried advice around helm-find-files, but doesn't seem to work
I didn't have linum-off set up properly. It overrides a function which global-linum-mode calls, so the latter has to be active in order for it to work.
; init.el
(require 'linum-off)
(global-linum-mode t)

Customizing emacs in .emacs file

I want emacs to start with specific settings by default. I found that I need to edit the .emacs file in my home directory and use LISP language. However I do get some errors. I need to have:
Windows split by vertical line (I work in C++ with headers and source files)
Column number mode
Cua-mode enabled (to work with normal copy, cut & paste shortcuts)
That's what I have in my .emacs file:
(column-number-mode)
(load "cua-mode")
(CUA-mode t)
(split-window-right)
I'ver tried coding two middle settings in one - (cua-mode). It didn't work out well.
The column-number-mode works, cua does not load and my window is split horizontally (top and bottom window). Where is my error? Thanks for feedback.
From the comments to the question:
if you're using Emacs 24.1 or later,
(column-number-mode)
(load "cua-mode")
(cua-mode t)
(split-window-right)
but if you're using an earlier version,
(column-number-mode)
(load "cua-mode")
(cua-mode t)
(split-window-horizontally)
By the way, the split-window-horizontally also works in later versions of Emacs (I'm using Emacs 25.2.1).

Emacs Whitespace Mode ignores whitespace-line-column and fill-column

I have an issue using Emacs 24.1.1 on Mac OS X. I'm editing Jade and CoffeeScript files, so I've turned on whitespace-mode for those file types.
What I'm seeing is that lines longer than 70 characters are highlighted with the whitespace-line font face, regardless of the setting of whitespace-line-column.
In this shot, it is clear that I've customized whitespace-line-column to track fill-column, and I've set fill-column to 120, but much shorter lines are being highlighted.
I've glanced over the code for the Jade mode and don't see anything that would explain the behavior, but I have only a passing understanding of Emacs Lisp.
Thanks in advance for any pointers!
You have to set whitespace-line-column before you activate whitespace-mode. That is, if you want to change its value it does not take effect unless you turn whitespace-mode off and on again. Ironically, that variable is not available for M-x customize until you have activated the mode once :-(
However, you can customize the global value of this variable by putting the following line in your .emacs file:
(setq whitespace-line-column 120)
Since your .emacs is evaluated when you start Emacs, the setting will take effect before you invoke whitespace-mode for the first time and should thus do what you want. If you don't want to set the value globally, but only for Jade files, put the following in your .emacs file instead:
(set (make-local-variable 'whitespace-line-column) 80)
(add-hook 'after-change-major-mode-hook
'(lambda () (when (eq major-mode 'jade-mode)
(setq whitespace-line-column 120))))
If you never want long lines to be highlighted specially at all, there is a third option you might want to consider. You could customize the variable whitespace-style (by typing M-x customize-variable ENTER whitespace-style ENTER) and in the value list remove the entries:
lines
lines-tail
(if any). This should turn off highlighting of long lines globally independent of the value of whitespace-line-column (again, only after you de- and re-activate whitespace mode).

Cant apply color theme to one frame in Emacs?

My .emacs file is here. I want the theme to change when I am in shell-mode. But what happens is that the theme gets applied to all the windows. I set the variable color-theme-is-global to nil, but the problem still persists.
(add-hook 'shell-mode-hook 'color-theme-monokai-terminal)
(set-variable 'color-theme-is-global nil)
These are the corresponding lines in my .emacs file. What should I do to make it work?
I usually start Emacs as a daemon and then open frames as needed. I use different color themes for X frames and terminal frames like so:
(require 'color-theme)
(color-theme-initialize)
(defun apply-color-theme (frame)
"Apply color theme to a frame based on whether its a 'real'
window or a console window."
(select-frame frame)
(if (window-system frame)
(color-theme-tango)
(color-theme-tango-black)))
(setq color-theme-is-global nil)
(add-hook 'after-make-frame-functions 'apply-color-theme)
You can replace the (if window-system ...) part with your check for shell-script-mode and the color-theme-X parts with your favorite themes.
There is one downside to this: if you don't start Emacs as a deamon, the customization will only kick in after you create a second frame, the first one that pops up will have the standard theme.
I think your terminology is off: in emacs-speak frame means what people normally mean by window in a graphical environment. (That is, the thing that has the close, minimize and maximize buttons and a titlebar, etc, is the "frame".) Whereas the things that show up when you do a C-x 3 (split-window) are called windows, and when you do something like M-x shell-mode you get a new buffer, which may or may not be in a new window.
Color themes are always frame-global (as far as I know, and it's certainly what the documentation suggests) the variable color-theme-is-global determines whether a single theme propagates across frames.
I'm thinking that the closest thing to what you want is something like (completely untested, probably broken):
(defun shell-mode-in-new-frame ()
(interactive)
(select-frame (make-frame))
(color-theme-monokai-terminal)
(shell-mode))
Although this does create a new frame, which isn't what you want.