I have in this my config file:
(defun untabify-everything ()
(untabify (point-min) (point-max)))
(defun untabify-everything-on-save ()
(add-hook 'before-save-hook 'untabify-everything) nil)
(add-hook 'before-save-hook 'untabify-everything-on-save)
but I want to exclude "Makefile" from this. How to do this?
Related
My emacs takes a few seconds to start up every time, which is slower than I'd expect. During that time, it says "contacting host: " marmalade-repo and melpa.
Is my current config a reasonable one? Is there a way I can speed it up, while still being able to install packages when I need them?
;; init.el --- Emacs configuration
;; INSTALL PACKAGES
;; --------------------------------------
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/"))
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar myPackages
'(better-defaults
paredit
idle-highlight-mode
ido-ubiquitous
find-file-in-project
smex
scpaste
ein
elpy
flycheck
material-theme
py-autopep8))
(package-refresh-contents)
(mapc #'(lambda (package)
(unless (package-installed-p package)
(package-install package)))
myPackages)
;; BASIC CUSTOMIZATION
;; --------------------------------------
(setq inhibit-startup-message t) ;; hide the startup message
(load-theme 'material t) ;; load material theme
(global-linum-mode t) ;; enable line numbers globally
;; PYTHON CONFIGURATION
;; --------------------------------------
(elpy-enable)
(elpy-use-ipython)
;; use flycheck not flymake with elpy
(when (require 'flycheck nil t)
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(add-hook 'elpy-mode-hook 'flycheck-mode))
;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
;; enable electric pair minor mode
(defun electric-pair ()
"If at end of line, insert character pair without surrounding spaces.
Otherwise, just insert the typed character."
(interactive)
(if (eolp) (let (parens-require-spaces) (insert-pair)) (self-insert-command 1)))
(add-hook 'python-mode-hook
(lambda ()
(define-key python-mode-map "\"" 'electric-pair)
(define-key python-mode-map "\'" 'electric-pair)
(define-key python-mode-map "(" 'electric-pair)
(define-key python-mode-map "[" 'electric-pair)
(define-key python-mode-map "{" 'electric-pair)))
;; Send line from code buffer
;; http://stackoverflow.com/questions/27777133/change-the-emacs-send-code-to-interpreter-c-c-c-r-command-in-ipython-mode/30774439#30774439
(defun my-python-line ()
(interactive)
(save-excursion
(setq the_script_buffer (format (buffer-name)))
(end-of-line)
(kill-region (point) (progn (back-to-indentation) (point)))
(if (get-buffer "*Python*")
(message "")
(run-python "ipython" nil nil))
;; (setq the_py_buffer (format "*Python[%s]*" (buffer-file-name)))
(setq the_py_buffer "*Python*")
(switch-to-buffer-other-window the_py_buffer)
(goto-char (buffer-end 1))
(yank)
(comint-send-input)
(switch-to-buffer-other-window the_script_buffer)
(yank))
(end-of-line)
(next-line)
)
(add-hook 'python-mode-hook
(lambda ()
(define-key python-mode-map "\C-cn" 'my-python-line)))
Recently, loading packages from MELPA has been really slow, I'm not so sure why. What you can do to get around this (or at least make sure it only happens once) is to run Emacs in daemon mode, and then connect to it whenever you want to edit a file. It means that the cost of loading is only incurred once. It's as simple as running emacs --daemon at startup. Then you connect via emacsclient.
I have this configuration but emacs still creates autosave files, which is driving me crazy. Please HELP.
;; no backup files
;; get rid of backup and autosave files
(defvar user-temporary-file-directory
(concat temporary-file-directory user-login-name "/"))
(make-directory user-temporary-file-directory t)
(setq backup-by-copying t)
(setq backup-directory-alist
`(("." . ,user-temporary-file-directory)
(,tramp-file-name-regexp nil)))
(setq auto-save-list-file-prefix
(concat user-temporary-file-directory ".auto-saves-"))
(setq auto-save-file-name-transforms
`((".*" ,user-temporary-file-directory t)))
(setq make-backup-files nil)
(setq auto-save-default nil)
I have setup cedet+auto complete and got the recommendation system to work. However whenever the drop down menu of recommendations is shown, I expect the results to be filtered as I enter characters.
This is the screenshot:
So as I type pu I expect the drop down menu to contain results like push_back. How do I get that?
This is my .emacs file(relevant portions):
;;; yasnippet
;;; should be loaded before auto complete so that they can work together
(require 'yasnippet)
(yas-global-mode 1)
(defun my:ac-c-header-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers)
(add-to-list 'achead:include-directories '"/usr/include/c++/4.8"))
(add-hook 'c++-mode-hook 'my:ac-c-header-init)
(add-hook 'c-mode-hook 'my:ac-c-header-init)
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(require 'auto-complete)
(ac-config-default)
(setq ac-auto-show-menu t)
(ac-flyspell-workaround)
;;cedet configuration
(semantic-mode 1)
(defun my:add-semantic-to-autocomplete ()
(add-to-list 'ac-sources 'ac-source-semantic))
(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
(global-ede-mode 1)
(global-semantic-idle-scheduler-mode 1)
(add-hook 'c-mode-hook 'my:add-semantic-to-autocomplete)
(add-hook 'c++-mode-hook 'my:add-semantic-to-autocomplete)
;; (defun my-semantic-hook ()
;; (imenu-add-to-menubar "TAGS"))
;; (add-hook 'semantic-init-hooks 'my-semantic-hook)
;(require 'semantic/ia)
;(require 'semantic/bovine/gcc)
(defun my-c-mode-cedet-hook ()
(add-to-list 'ac-sources 'ac-source-gtags)
(add-to-list 'ac-sources 'ac-source-semantic))
(add-hook 'c-mode-common-hook 'my-c-mode-cedet-hook)
(add-hook 'c++-mode-common-hook 'my-c-mode-cedet-hook)
(semanticdb-enable-gnu-global-databases 'c-mode t)
(semanticdb-enable-gnu-global-databases 'c++-mode t)
I suppose you can use ac-isearch. You can invoke it by C-s when completion tooltip is popuped.
popup completion tooltip(M-x auto-complete or auto start)
invoke ac-isearch(C-s)
filtering completions
When I try to export a org-mode file to odf I end up with a corrupt output file. I narrowed the problem down to that the odt-file (which in fact is a zip file) contained a file named content_flymake.xml. If I remove that file, I can open the it without a problem.
Now I'm stucked. I don't know what to do next.
A grep of flymake in my config files:
nine#nine-laptop:~/.emacs.d/configfile$ grep -A 5 -B 5 -R "flymake" *
blocks/python.el-
blocks/python.el-(add-to-list 'load-path "~/.emacs.d/vendor")
blocks/python.el-
blocks/python.el-; Make Flymake work with python
blocks/python.el-(add-to-list 'load-path "~/.emacs.d/plugins")
blocks/python.el:(add-hook 'find-file-hook 'flymake-find-file-hook)
blocks/python.el-
blocks/python.el:(when (load "flymake" t)
blocks/python.el: (defun flymake-pyflakes-init ()
blocks/python.el: (let* ((temp-file (flymake-init-create-temp-buffer-copy
blocks/python.el: 'flymake-create-temp-inplace))
blocks/python.el- (local-file (file-relative-name
blocks/python.el- temp-file
blocks/python.el- (file-name-directory buffer-file-name))))
blocks/python.el- (list "pycheckers" (list local-file))))
blocks/python.el: (add-to-list 'flymake-allowed-file-name-masks
blocks/python.el: '("\\.py\\'" flymake-pyflakes-init)))
blocks/python.el:(load-library "flymake-cursor")
blocks/python.el:(global-set-key [f10] 'flymake-goto-prev-error)
blocks/python.el:(global-set-key [f11] 'flymake-goto-next-error)
blocks/python.el-
blocks/python.el-(require 'ipython)
blocks/python.el-
blocks/python.el-;(define-key py-mode-map (kbd "M-TAB") 'anything-ipython-complete)
blocks/python.el-;(define-key py-shell-map (kbd "M-TAB") 'anything-ipython-complete)
--
emacs- ;; If you edit it by hand, you could mess it up, so be careful.
emacs- ;; Your init file should contain only one such instance.
emacs- ;; If there is more than one, they won't work right.
emacs- )
emacs-
emacs:; Workaround for broken flymake configuration (Might be fixed in future versions)
emacs:(defun flymake-xml-init ()
emacs: (list "xmlstarlet" (list "val" "-e" (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace))))
emacs-
emacs-;;;;;;;;;;;;;;;;;;
emacs-; Mutt mail-mode ;
emacs-;;;;;;;;;;;;;;;;;;
emacs-(add-to-list 'auto-mode-alist '(".*mutt.*" . message-mode))
And my org-mode configuration
nine#nine-laptop:~/.emacs.d/configfile$ cat blocks/orgmode.el
;; Org mode
(add-to-list 'load-path "~/.emacs.d/plugins/org-mode/lisp/")
;; odt-support
(require 'ox-odt)
;(require 'org-mode)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
(setq org-agenda-files (list "~/Dokument/org/arbete.org"
"~/Dokument/org/calendar.org"))
(setq org-startup-indented t)
;; Default ODF style
;(setq org-export-odt-styles-file "~/.emacs.d/org-mode-odtconv/predikan-style.xml")
;(setq org-default-notes-file (concat org-directory "/anteckningar.org"))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-capture)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
;; Automatic Org mode pull and push
;(add-hook 'after-init-hook 'org-mobile-pull)
;(add-hook 'kill-emacs-hook 'org-mobile-push)
One possibility is to disable the flymake-find-file-hook while running org-export-as-odt. The following lines may work:
(defadvice org-export-as-odt (around remove-flymake-hook first act)
(let ((find-file-hook find-file-hook))
(remove-hook 'find-file-hook 'flymake-find-file-hook)
ad-do-it))
You can also try to customize flymake-allowed-file-name-masks and remove the .xml binding there. But this means that no xml file would run under flymake by default anymore.
I'm trying to batch indent source files using emacs. I'm using the command:
$ emacs -batch Source.h -l emacs-format-file.el -f emacs-format-function
where emacs-format-file.el contains:
(defun emacs-format-function ()
(c-set-style "gnu")
(setq c-basic-offset 4)
(c-set-offset 'access-label nil)
(c-set-offset 'substatement-open 0)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max))
(save-buffer)
)
Emacs indents the file to my liking with one exception. The "public", "private", and "protected" keywords are all indented an extra space:
class Foo
{
-public:
+ public:
I want to align these keywords with the preceding open bracket. Based on this question I thought setting 'access-label' would fix this but it doesn't seem to have any effect.
What am I missing?
Turns out that emacs was processing the header file as C instead of C++. The fix was to change the .el file to manually switch to C++ mode:
(defun c++-indent-region ()
(c++-mode)
(c-set-style "gnu")
(setq c-basic-offset 4)
(indent-region (point-min) (point-max) nil)
(untabify (point-min) (point-max))
(save-buffer)
)