1. Roma Sokolov
  2. confs

Commits

Roma Sokolov  committed 2c44cbe

emacs goodies

  • Participants
  • Parent commits 942dccb
  • Branches default

Comments (0)

Files changed (5)

File .emacs.d/init.el

View file
  • Ignore whitespace
 
 (require 'server)
 (if (server-running-p)
-   (server-force-delete))
-(server-start)
+    (server-force-delete))
 
 (defun add-to-path (dir)
   (add-to-list 'load-path

File .emacs.d/load/elpackages_init.el

View file
  • Ignore whitespace
   :after (progn () (global-set-key (kbd "C-x p") 'piu))))
 
 (el-get-add
+ (:name puc
+  :type http
+  :url "http://paste.undev.cc/puc.el"
+  :features puc))
+
+
+(el-get-add
  (:name tuareg-mode
   :after (progn ()
                 (setq ocaml-compiler "ocamlfind ocamlc")
   :features project-root
   :after (progn ()
            (global-set-key (kbd "C-c p f") 'project-root-find-file)
+           (global-set-key (kbd "C-c p t") 'ty:project-root-find-tag)
            (global-set-key (kbd "C-c p g") 'project-root-grep)
            (global-set-key (kbd "C-c p a") 'project-root-ack)
            (global-set-key (kbd "C-c p d") 'project-root-goto-root)
            (global-set-key (kbd "C-c p l") 'project-root-browse-seen-projects)
            (global-set-key (kbd "C-c p b") 'project-root-switch-buffer)
-
            (setq project-roots
                  `(
                    ("Makefiledriven"
                    ("Generic Mercurial project"
                     :root-contains-files (".hg"))
                    ("Generic git project"
-                    :root-contains-files (".git")))))))
+                    :root-contains-files (".git"))
+                   ("SConsdriven project"
+                    :root-contains-files ("SConscript" "SConstruct")
+                    :filename-regex ,(regexify-ext-list '(c h m cu))
+                    :exclude-paths '("build")))))))
 
 (el-get-add
  (:name sudo-save
 (el-get-add
  (:name magit))
 
+(el-get-add
+ (:name clojure-mode))
 
 (el-get-add
- (:name magit))
-
-(el-get-add
- (:name rust-mode))
-
-(el-get-add
- (:name lua-mode))
-
-(el-get-add
- (:name clojure-mode))
+ (:name nrepl))
 
 (el-get-add
  (:name paredit
                 (add-hook 'emacs-lisp-mode-hook 'enable-paredit-mode)
                 (add-hook 'lisp-interaction-mode-hook 'enable-paredit-mode)
                 (add-hook 'lisp-mode-hook 'enable-paredit-mode)
-                (add-hook 'ielm-mode-hook 'enable-paredit-mode))))
+                (add-hook 'clojure-mode-hook 'enable-paredit-mode)
+                (add-hook 'nrepl-mode-hook 'enable-paredit-mode)
+                (add-hook 'ielm-mode-hook 'enable-paredit-mode)
+                (define-key paredit-mode-map (kbd "M-q") 'paredit-reindent-defun)
+                (define-key paredit-mode-map (kbd "RET") 'paredit-newline)
+                (define-key paredit-mode-map (kbd "M-c") 'pr-copy-parenthesis))))
 
 (el-get-add
  (:name slime))

File .emacs.d/load/funs_init.el

View file
  • Ignore whitespace
     (kill-new path)
     (message "%s" path)))
 
-(defun ty:util-open-file (fname ext msg)
-  (interactive)
-  (let* ((newname (concat fname ext)))
-    (if (file-exists-p newname)
-        (find-file newname)
-      (message msg))
-    ))
+(defun ty:project-root-open-file (fname ext)
+  (let* ((newnname (concat fname ext))
+         (file-to-open (ty:project-root-find-file newnname)))
+    (if file-to-open
+        (find-file file-to-open)
+      nil)))
 
+(defun ty:project-root-find-file (filename)
+  (with-project-root
+      (let* ((project-files (project-root-files))
+             (project-filenames (mapcar 'car project-files))
+             (found-filename (ty:find-first
+                              (lambda (s) (string-prefix-p filename s))
+                              project-filenames)))
+        (cdr (assoc found-filename project-files)))))
+
+(defun ty:filter (condp lst)
+  (delq nil (mapcar (lambda (x) (and (funcall condp x) x)) lst)))
+
+(defun ty:find-first (condp lst)
+  (car (ty:filter condp lst)))
+
+(defun ty:project-root-find-tag (prompt)
+  (interactive (find-tag-interactive "Find tags in project: "))
+  (let ((project-tags-file-name (ty:project-root-find-file "TAGS")))
+    (message project-tags-file-name)
+    (setq tags-file-name project-tags-file-name)
+    (find-tag prompt)))

File .emacs.d/load/keys_init.el

View file
  • Ignore whitespace
 (global-set-key (kbd "M-g") 'goto-line)
 (global-set-key (kbd "M-?") 'help-command)
 (global-set-key (kbd "C-x C-r") 'query-replace-regexp)
-(global-set-key (kbd "M-.") 'find-tag)
 
 (global-set-key (kbd "C-x C-d") 'dired-jump)
 

File .emacs.d/load/modes_init.el

View file
  • Ignore whitespace
 
 ;; ObjC
 
-(defun objc-open-interface ()
+(defun c-open-header ()
   (interactive)
   (let* ((filename (file-name-nondirectory buffer-file-name))
-         (basename (file-name-sans-extension filename)))
-    (cond
-     ((string-match ".*\\.m\$" filename)
-      (ty:util-open-file basename ".h" "No Interface Found!")
-      )
-     ((string-match ".*\\.h\$" filename)
-      (ty:util-open-file basename ".m" "No Implementation Found!"))
-     )))
+         ;; to catch .m.bak , m.in etc
+         (aux-name (file-name-sans-extension filename))
+         (basename (file-name-sans-extension aux-name)))
+    (cond ((or (string-match ".*\\.m\$" filename) (string-match ".*\\.m\$" aux-name))
+          (when (not (ty:project-root-open-file basename ".h"))
+            (message "Can not open header")))
+          ((string-match ".*\\.h$" filename)
+           (when (not (ty:project-root-open-file basename ".m"))
+             (when (not (ty:project-root-open-file basename ".c"))
+               (message "Can not open implementation")))))))
 
 (add-hook 'objc-mode-hook
           (lambda ()
-            (global-set-key (kbd "C-c i") 'objc-open-interface)
+            (global-set-key (kbd "C-c i") 'c-open-header)
             (setq comment-start "/*")
             (setq comment-end "*/")
             (subword-mode)
             (c-set-offset 'substatement-open 0)
 ))
 
+(add-hook 'c-mode-hook
+          (lambda ()
+            (global-set-key (kbd "C-c i") 'c-open-header)
+            (setq comment-start "/*")
+            (setq comment-end "*/")
+            (subword-mode)
+            (setq tab-width 8)
+            (setq c-basic-offset 8)
+            (c-set-offset 'substatement-open 0)
+))
+
+
+;; lisp
+
+(add-hook 'lisp-mode-hook
+          (lambda ()
+            (setq lisp-indent-function 2)
+            (setq lisp-indent-offset 2)))
+
 
 ;; Haskell