.emacs configuration overridden when starting emacs - emacs

When I edit a file with emacs, the configuration stored in the .emacs file is read (I can judge this by the font size). However, not a second passes and both the window and font sizes decrease. It seems that my custom configuration is being overridden. I don't know where this additional configuration is stored.
System: Light Ubuntu 18.04
My .emacs file:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(setq tab-stop-list t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "DejaVu Sans Mono" :foundry "PfEd" :slant normal :weight normal :height 143 :width normal)))))
; disable the wellcome screen
(setq inhibit-startup-screen t)
;; rebind C-x C-b to invoke buffer-menu rather than list-buffers
(global-set-key "\C-x\C-b" 'buffer-menu)
; open list of buffers in active window
(global-set-key "\C-x\C-b" 'buffer-menu)
; Directory to place the backup files
(setq backup-directory-alist `(("." . "~/.emacs.d/backup_files")))
; Disable Large file size warning
(setq large-file-warning-threshold nil)
;; show line numbers
(global-linum-mode 1)

Following #prosoitos advice from the comment's section in the original question:
created $HOME/.Xresouces file containing the following line
emacs*font: DejaVu Sans Mono 16
in the terminal, type xrdb $HOME/.Xresouces

Related

Emacs trident-mode key-binding not getting activated

I am a beginner in Emacs. I am trying to use trident-mode (for Parenscript). I have copied the commands from the trident-mode site trident-site-here into my init.el file. But the trident-mode keybindings C-c C-e don't work. I am copy-pasting my complete init.el file below:
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;;;; Added from Melpa.org
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
(when no-ssl (warn "\
Your version of Emacs does not support SSL connections,
which is unsafe because it allows man-in-the-middle attacks.
There are two things you can do about this warning:
1. Install an Emacs version that does support SSL and be safe.
2. Remove this warning from your init file so you won't see it again."))
(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
)
; Commented coz it is there in the next line (package-initialize)
;;;; End Melpa.ord addition
(package-initialize)
(load (expand-file-name "~/quicklisp/slime-helper.el"))
;; Replace "sbcl" with the path to your implementation
(setq inferior-lisp-program "sbcl")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages (quote (trident-mode))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "DejaVu Sans Mono" :foundry "PfEd" :slant normal :weight normal :height 158 :width normal)))))
;;; From Trident-model.el site on Github
(add-to-list 'auto-mode-alist (cons "\\.paren\\'" 'lisp-mode))
(add-hook 'lisp-mode-hook
#'(lambda ()
(when (and buffer-file-name
(string-match-p "\\.paren\\>" buffer-file-name))
(unless (slime-connected-p)
(save-excursion (slime)))
(trident-mode +1))))
;;;; From same site, key bindings
(trident-add-keys-with-prefix "C-c C-e")
;; The key sequence for trident-eval-region is "e r", so it's now bound to "C-c C-e er"
**This is What is Not getting Activated**
One thing that I observe if I open a .paren file is that, repl buffer gets to top, and file buffer (where .paren file is shown) gets below. I don't know how to fix that. But I did interchange them by clicking on the buffer names to change. I don't know if it is relevant, but I am writing it just in case that is the culprit. If possible I would prefer regular (program text on top and repl buffer below) setting.
What am I doing wrong? Thanks for the help.
Edit-1: I have added link to the trident-mode-site.
Thanks Phils Phils' answer worked.
I am posting the change I made:
Earlier I was using:
(trident-add-keys-with-prefix "C-c C-e")
This was not working. With Phil's suggestion, I replaced that line with
(with-eval-after-load "trident-mode" (trident-add-keys-with-prefix "C-c C-e"))
This Worked.
I am a newbie, so I have detailed a seemingly simple/obvious answer. This is to help other newbies like me. We can get confused about the smallest of things. :-)
Phils, thank you again.

Apply a Built-in Style to a file with Emacs

I've a c file written like this:
int main(void){
}
I would like to change every bracket in the file according to the "linux" format.
int main(void)
{
}
How can I do this with Emacs?
EDIT 1:
This is my .emacs file:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(custom-enabled-themes (quote (tango-dark)))
'(inhibit-startup-screen t)
'(package-archives
(quote
(("melpa" . "https://melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(setq make-backup-files nil) ; stop creating backup~ files
(setq auto-save-default nil) ; stop creating #autosave# files
(setq c-default-style "linux"
c-basic-offset 4)
EDIT 2:
Solved by creating an emacs macro that calls GNU indent.
Primary source of how to do this is the emacs wiki page. To use linux style in emacs:
(setq c-default-style "linux")
put the above line in your ~/.emacs or ~/.config/emacs/config if you have xdg paths defined for emacs.
CtrlM\ will reindent an arbitrary region, so after you set the c-default-style to linux simply select the content of the buffer and re-indent. More on this at CC-Mode manual

How to run racket with geiser: getting error:Can't exec program: /Applications/Racketv6.0/DrRacket.app

I am new to Emacs and I am having a bit of trouble. I am looking to run racket from Emacs using Geiser. I told Emacs where racket is as follows:
(setq geiser-racket-binary "/Applications/Racket\ v6.0/DrRacket.app")
(I took this from StackOverflow question: Setting Racket Geiser Emacs Path.)
I start by compiling the racket code that is saved. However, when I attempt to hit M-x followed by run-geiser, it then prompts me for a Scheme implementation. At this point I type racket. Emacs now opens a racket REPL buffer and in that buffer it leaves the error:
Can't exec program: /Applications/Racketv6.0/DrRacket.app .
If it helps, here is my .emacs file:
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(geiser-repl-startup-time 20000)
'(package-archives (quote (("gnu" . "elpa gnu packages website") ("melpa" . "http://melpa.milkbox.net/#/"))))
'(package-directory-list (quote ("/Applications/Emacs.app/Contents/Resources/site-lisp/elpa")))
'(python-python-command "/usr/local/bin/python3"))
(setq geiser-racket-binary "/Applications/Racket\ v6.0/DrRacket.app")
(setq-default cursor-type 'bar)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:inherit nil :stipple nil :background "controlDarkShadowColor" :foreground "Green" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 120 :width normal :foundry "apple" :family "Monaco")))))
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
I think you are referencing the wrong executable.
"DrRacket" is an IDE (with a graphical user interface) for editing Racket code. From man drracket:
DrRacket is the Racket programming environment.
Try setting geiser-racket-binary to the location of the racket executable (which is the "core Racket implementation") instead.
EDIT
If the naming scheme of the Mac installation of Racket is anything like the one used for the Linux installation, there should be a binary called Racket or racket in a location similar to where you can find the DrRacket (or drracket) binary:
$ locate racket
...
/usr/bin/drracket
/usr/bin/gracket
/usr/bin/gracket-text
/usr/bin/racket
...
(Not suggesting that you will find the binaries in /usr/bin/, just trying to illustrate that there is a good chance all binaries that are possibly relevant are located in the same directory.)
On OS X xxx.app is technically a directory. The actual executable file is located in Content/MacOS/xxx (if my memory serves me correctly).
EDIT: In other words, you should write something like:
(setq geiser-racket-binary "/Applications/Racket\ v6.0/DrRacket.app/Content/MacOS/DrRacket")
Note: I'n not at my Mac so I can't verify the details right now.

How to load file into buffer and switch to buffer on start up in Emacs

I have a TODO file that I load emacs up to use 90% of the time. When I load emacs though it defaults to loading the scratch buffer. I would like it to load the TODO file initially. I'm very new to Emacs and have tried searching round for ways to do this using the .emacs file but nothing has worked so far.
Here are my attempts:
1: Use find-file to get the file and switch-to-buffer to load it to the screen
(switch-to-buffer (find-file "c:/Users/Seb/Documents/Emacs/TODO_List.org"))
2: Use pop-to-buffer to load the file instead
(pop-to-buffer (find-file "c:/Users/Seb/Documents/Emacs/TODO_List.org"))
3: Save the desktop so it loads the next time
(desktop-save-mode 1)
None of these are working.
Here is my full .emacs file, as you can see it's barely used!
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
; '(inhibit-startup-buffer-menu t)
'(inhibit-startup-screen t)
'(initial-buffer-choice t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; Set the current directory to the Emacs Documents dir
(cd "C:/Users/Seb/Documents/Emacs")
;; Open TODO list on start up
(pop-to-buffer (find-file "c:/Users/Seb/Documents/Emacs/TODO_List.org"))
;; Turn off the annoying tool bar at startup - to turn back on
;; just type M-x tool-bar-mode
(tool-bar-mode -1)
;; Move the mouse when cursor is near
(mouse-avoidance-mode 'cat-and-mouse)
;; This enables saving the current desktop on shutdown.
(desktop-save-mode 1)
;; XML Pretty Print
(defun xml-pretty-print (begin end)
"Pretty format XML markup in region. You need to have nxml-mode
http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
this. The function inserts linebreaks to separate tags that have
nothing but whitespace between them. It then indents the markup
by using nxml's indentation rules."
(interactive "r")
(save-excursion
(nxml-mode)
(goto-char begin)
(while (search-forward-regexp "\>[ \\t]*\<" nil t)
(backward-char) (insert "\n"))
(indent-region begin end))
(message "Ah, much better!"))
In your startup file, you have this line:
'(initial-buffer-choice t))
as part of your "custom-set-variables" command. The documentation string for "initial-buffer-choice" is:
Buffer to show after starting Emacs. If the value is nil and
inhibit-startup-screen' is nil, show the startup screen. If the
value is string, visit the specified file or directory using
find-file'. If t, open the `scratch' buffer.
So, the value that you've specified ('t') is causing the *scratch* buffer to be displayed after startup. Change this line to the following and your issue should be resolved:
'(initial-buffer-choice "c:/Users/Seb/Documents/Emacs/TODO_List.org"))

what is custom-set-variables and faces in my .emacs?

this is in my .emacs can I mess with it or not?
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(better-fringes-bitmap ((t (:foreground "#00dd44"))))
'(font-lock-string-face ((((class color) (min-colors 88) (background light)) (:foreground "#113355")))))
so far I am adding everything I want above these lines...
These blocks are added by the customize interface, as Noufal pointed out. You can move them to a separate file, though, if you like.
Just add this to your ~/.emacs.d/init.el:
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
or, if you're still using an old-fashioned ~/.emacs file:
(setq custom-file "~/.custom.el")
(load custom-file)
A slightly more complex snippet that will work in either case is:
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file)
These are lines added to the file when you use the customise system. They're generated when you use customize-*. By default, the customisation options are stored in the .emacs file. You don't usually edit these by hand. You have to use the customize-* commands to edit them.
Don't add anything to these lines manually — your changes will be vanished by emacs on some events. Instead add custom variables with customize-set-variable and custom faces with set-face-attribute:
(customize-set-variable 'blink-cursor-mode nil)
(set-face-attribute 'default nil :family "DejaVu Sans Mono")
In order to customize face of some package one sometimes need to request the package first, and after that set its face:
(require 'mumamo)
(set-face-attribute 'mumamo-background-chunk-major nil :background nil)