Code Monkey home page Code Monkey logo

Comments (18)

tonini avatar tonini commented on July 22, 2024

Hi @fremontmj

I've just installed Alchemist (it looks great!). I've also installed company (and uninstalled auto-complete). Completion generally works...

You mean Completion generally works for other modes but not for elixir-mode?

We had this kind of situation before. I think the problem could be with the alchemist-backend registration. Can I have a look at your emacs config?

Could you also paste the content of the company-backends list here please.

Thanks

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

@tonini Thanks for looking into this.

Completion works in elixir-mode - I can complete my own function names etc., but no suggestions come up when I try to complete Elixir libraries.

Here's company-backends:

company-backends is a variable defined in `company.el'.
Its value is (alchemist-company company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-ropemacs company-cmake company-capf
(company-dabbrev-code company-gtags company-etags company-keywords)
company-oddmuse company-files company-dabbrev)

Here's my init.el:

;;; package --- Summary
;;; Commentary:
;;; Code:
;;; all above here just to get flycheck to shut the hell up

(package-initialize)
(require 'cask "/usr/local/Cellar/cask/0.7.2/cask.el")
(cask-initialize)
(require 'pallet)
(recentf-mode 1)

; use evil-escape to escape out of everything
; must be ahead of the loading of evil-escape
(setq evil-escape-key-sequence (kbd ",,"))

;; use C-u as scroll-up
(setq-default evil-want-C-u-scroll t)

; use exec-path-from-shell package to initialize emac's exec-path variable from the shell
(when (memq window-system '(mac ns))
(exec-path-from-shell-initialize))

(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa-stable" . "http://melpa-stable.milkbox.net/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")
))

(setq inhibit-startup-screen t)
(custom-set-variables
'(initial-frame-alist (quote ((fullscreen . maximized))))) ;; start maximized

;; Show keystrokes
(setq echo-keystrokes 0.02)

; configure smooth-scrolling
(setq smooth-scroll-margin 10)

; configure evil-leader
; should be before evil-mode is enabled, so initial buffers have it
(global-evil-leader-mode)
(setq evil-leader/in-all-states 1)

;; Don't wait for any other keys after escape is pressed.
(setq evil-esc-delay 0)

; KEYMAP

; make moving between windows convenient
(global-set-key (kbd "C-c h") 'windmove-left)
(global-set-key (kbd "C-c j") 'windmove-down)
(global-set-key (kbd "C-c k") 'windmove-up)
(global-set-key (kbd "C-c l") 'windmove-right)

;(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)

(evil-leader/set-leader "")

; keymaps from spacemacs
;; Universal argument ---------------------------------------------------------
(evil-leader/set-key "u" 'universal-argument)
;; shell command -------------------------------------------------------------
(evil-leader/set-key "!" 'shell-command)
;; switch back and forth between two last buffers -----------------------------
(evil-leader/set-key "TAB" 'spacemacs/last-buffer)
;; BUFFERS --------------------------------------------------------------------
(evil-leader/set-key
; "bh" 'helm-recentf
"bh" 'helm-my-buffers
;"bd" 'delete-current-buffer-file
"be" 'spacemacs/safe-erase-buffer
"bK" 'kill-other-buffers
"bk" 'ido-kill-buffer
"b C-k" 'kill-matching-buffers-rudely
"bn" 'switch-to-next-buffer
"bp" 'switch-to-prev-buffer
"bR" 'spacemacs/safe-revert-buffer
"br" 'rename-current-buffer-file
"bw" 'toggle-read-only)
;; ALCHEMIST ------------------------------------------------------------------
(evil-leader/set-key
"ato" 'alchemist-project-open-tests-for-current-file
"ata" 'alchemist-mix-test
"atb" 'alchemist-mix-test-this-buffer
"atp" 'alchemist-mix-test-at-point
"amc" 'alchemist-mix-compile
"amr" 'alchemist-mix-run
)
;; describe functions ---------------------------------------------------------
;(evil-leader/set-key
;"hdf" 'describe-function
;"hdk" 'describe-key
;"hdm" 'describe-mode
;"hdv" 'describe-variable)

;; helm
(evil-leader/set-key
"hw" 'helm-multi-swoop-all
"hs" 'helm-etags-select)

;; org-mode
(evil-leader/set-key
"on" 'org-capture
)

;; org-capture note
(define-key evil-normal-state-map (kbd "C-a") (lambda ()
(interactive)
; (org-capture)
(call-interactively (org-capture "n"))
))

;; tern
(evil-leader/set-key
"ts" 'tern-find-definition
"tr" 'tern-rename-variable
"td" 'tern-get-docs
)

(evil-leader/set-key
"-" 'my-split-window-horizontally
"s" 'helm-multi-swoop-all
"m" 'helm-imenu
"x" 'helm-M-x
; "t" 'generate-riffer-ctags
"," 'evil-ace-jump-word-mode ; for Ace Jump (word)
"l" 'evil-ace-jump-line-mode ; for Ace Jump (line)
"." 'evil-ace-jump-char-mode ; for Ace Jump (char)
"q" 'flycheck-list-errors
"X" 'execute-extended-command ; replacement for alt-x
"S" 'save-and-kill-buffer
"cp" 'helm-projectile
"wo" 'other-window
"wka" 'delete-other-windows ; WINDOW KILL ALL
"wkt" 'delete-window ; WINDOW KILL THIS ONE
"wkn" 'close-and-kill-next-pane ; WINDOW KILL NEXT ONE
"wb" 'browse-url
"i" 'evilnc-comment-or-uncomment-lines
"l" 'evilnc-quick-comment-or-uncomment-to-the-line
"p" 'evilnc-comment-or-uncomment-paragraphs
"h" 'helm-mini
"cD" 'dash-at-point
"g" 'magit-status ; GIT
"emc" 'elixir-mix-compile ; ELIXIR MIX COMPILE
"rd" 'nodejs-repl-eval-dwim ; Do What I Mean
"rb" 'nodejs-repl-eval-buffer
"rf" 'nodejs-repl-eval-function
)

(defun save-and-kill-buffer ()
(interactive)
(save-buffer)
(kill-this-buffer))

;helm-man-woman

; simulate vim's "nnoremap 10jzz"
;; (define-key evil-normal-state-map " " (lambda ()
;; (interactive)
;; (next-line 10)
;; (evil-scroll-line-down 10)
;; ))

;; ; simulate vim's "nnoremap 10kzz"
;; (define-key evil-normal-state-map (kbd "DEL") (lambda ()
;; (interactive)
;; (previous-line 10)
;; (evil-scroll-line-up 10)
;; ))

;c-k/c-j for page down/up
(define-key evil-normal-state-map (kbd "C-k") (lambda ()
(interactive)
(evil-scroll-up nil)))
(define-key evil-normal-state-map (kbd "C-j") (lambda ()
(interactive)
(evil-scroll-down nil)))

;;; Make j/k movement keys go up/down accross rapped lines.
(define-key evil-normal-state-map (kbd " ") 'evil-next-visual-line)
(define-key evil-motion-state-map (kbd " ") 'evil-next-visual-line)
(define-key evil-normal-state-map (kbd " ") 'evil-previous-visual-line)
(define-key evil-motion-state-map (kbd " ") 'evil-previous-visual-line)

; j/k goes to next visual line when wrapped
(define-key evil-normal-state-map (kbd "j") 'evil-next-visual-line)

(define-key evil-normal-state-map (kbd "k") 'evil-previous-visual-line)

(evil-mode t)
; NOTE: this doesn't seem to be taking effect. I end up having to type this into the minibuffer to make it take hold - someone else must be setting it...
(setq evil-shift-width 2) ; indent line n spaces with '>>' and '<<' commands
; THIS solved the problem...
(add-hook 'after-change-major-mode-hook
(function (lambda ()
(setq evil-shift-width 2))))

;; makes jump list mimic vim behavior (for instance, can go across files)
(require 'evil-jumper)

(global-evil-surround-mode 1)

;; NOT YET TESTED seen these in other .emacs files and they might be interesting. Not yet tested...
;; Make HJKL keys work in special buffers
;; (evil-add-hjkl-bindings magit-branch-manager-mode-map 'emacs
;; "K" 'magit-discard-item
;; "L" 'magit-key-mode-popup-logging)
;; (evil-add-hjkl-bindings magit-status-mode-map 'emacs
;; "K" 'magit-discard-item
;; "l" 'magit-key-mode-popup-logging
;; "h" 'magit-toggle-diff-refine-hunk)
;; (evil-add-hjkl-bindings magit-log-mode-map 'emacs)
;; (evil-add-hjkl-bindings magit-commit-mode-map 'emacs)
;; (evil-add-hjkl-bindings occur-mode 'emacs)

;;; END NOT YET TESTED

;; END EVIL SETTINGS

; guide-key configuration
(setq guide-key/guide-key-sequence '("," "C-x r" "C-x 4"))
(setq guide-key/recursive-key-sequenece-flag t)
(guide-key-mode 1)

(projectile-global-mode)

;; this shouldn't be required, but .ex files are not automatically being highlighted...
; hmm, doesn't work reliably
; can use :elixir-mode to turn on manually
(add-to-list 'auto-mode-alist '(".ex'" . elixir-mode))

; flycheck configuration
(add-hook 'after-init-hook #'global-flycheck-mode)

(setq flycheck-check-syntax-automatically '(idle-change))

(global-flycheck-mode t)

(load-theme 'solarized-light t)

; turn off cruft
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))

; yasnippet configurati:on
(yas-global-mode 1)
(add-to-list 'yas/root-directory "~/.emacs.d/snippets/yasnippet-snippets")

; uniquely name buffers by adding :

after them
(require 'uniquify)
(setq
uniquify-buffer-name-style 'post-forward
uniquify-separator ":")

;helm
;(add-to-list 'load-path "Users/michaelfremont/.emacs.d/helm")
(require 'helm-config)
;(require 'helm-misc)
;(require 'helm-swoop)
;(require 'helm-dash)
;(require 'helm-projectile)
(helm-mode 1)

; use same vertical or horizontal split as last time; can toggle interactively with C-t in a helm window
(setq helm-reuse-last-window-split-state t)

(setq helm-quick-update t)
(setq helm-bookmark-show-location t)
(setq helm-buffers-fuzzy-matching t)

                   ;helm-c-source-projectile-files-list

(defun helm-my-buffers ()
(interactive)
(helm-other-buffer '(helm-c-source-buffers-list
helm-c-source-elscreen
helm-c-source-recentf
; helm-c-source-ctags
)
"helm-my-buffers"))

(defun helm-mini ()
"Preconfigured `helm' lightweight version (buffer -> recentf)."
(interactive)
(require 'helm-files)
(let ((helm-ff-transformer-show-only-basename nil))
(helm-other-buffer '(helm-source-buffers-list
helm-source-recentf
helm-source-buffer-not-found)
"helm mini")))

; let helm give pcompletion in eshell
(add-hook 'eshell-mode-hook
#'(lambda ()
(define-key eshell-mode-map
[remap eshell-pcomplete]
'helm-esh-pcomplete)))

; enable helm eshell history
(add-hook 'eshell-mode-hook
#'(lambda ()
(define-key eshell-mode-map
(kbd "M-p")
'helm-eshell-history)))

;; helm-swoop configuration
;; When doing evil-search, hand the word over to helm-swoop
(define-key evil-motion-state-map (kbd "M-i") 'helm-swoop-from-evil-search)

;; Split direcion. 'split-window-vertically or 'split-window-horizontally
(setq helm-swoop-split-direction 'split-window-horizontally)

;auto-complete
; this is not working for .ex files, so I've defined a keybinding to turn AC on for a buffer
;; auto-complete package
;(ac-config-default)
;(global-auto-complete-mode t)
; won't turn on ac in elixir-mode without this, don't know why...
;(add-to-list 'ac-modes 'elixir-mode)

; company package (company-mode)
; alchemist uses company mode rather than auto-complete
(add-hook 'after-init-hook 'global-company-mode)
(setq alchemist-project-compile-when-needed t)

; does not work in terminal emacs
;; Some modes start with evil turned off (like M-x list-packages) so different
;; cursor colors are useful.
(let ((color-emacs "cyan")
(color-evil "green")
(color-motion "red"))
(setq-default cursor-type (bar ,color-emacs)) (setq evil-emacs-state-cursor(bar ,color-emacs))
(setq evil-normal-state-cursor (box ,color-evil)) (setq evil-insert-state-cursor(bar ,color-evil))
(setq evil-visual-state-cursor (hollow ,color-evil)) (setq evil-operator-state-cursor(hollow ,color-evil))
(setq evil-replace-state-cursor (hbar ,color-evil)) ;;motion state is when some of evil is disabled (like in the function help and "C-h i" pages). ;;give it a special color I know when it is not full-evil bindings. (setq evil-motion-state-cursor(box ,color-motion)))

(defun my-send-string-to-terminal (string)
(unless (display-graphic-p) (send-string-to-terminal string)))

;; terminal colors by mode also on console
(defun my-evil-terminal-cursor-change ()
(when (string= (getenv "TERM_PROGRAM") "iTerm.app")
(add-hook 'evil-insert-state-entry-hook (lambda () (my-send-string-to-terminal "\e]50;CursorShape=1\x7")))
(add-hook 'evil-insert-state-exit-hook (lambda () (my-send-string-to-terminal "\e]50;CursorShape=0\x7"))))
(when (and (getenv "TMUX") (string= (getenv "TERM_PROGRAM") "iTerm.app"))
(add-hook 'evil-insert-state-entry-hook (lambda () (my-send-string-to-terminal "\ePtmux;\e\e]50;CursorShape=1\x7\e")))
(add-hook 'evil-insert-state-exit-hook (lambda () (my-send-string-to-terminal "\ePtmux;\e\e]50;CursorShape=0\x7\e")))))

(add-hook 'after-make-frame-functions (lambda (frame) (my-evil-terminal-cursor-change)))
(my-evil-terminal-cursor-change)

; recenter after search
(defadvice
isearch-forward
(after isearch-forward-recenter activate)
(recenter))
(ad-activate 'isearch-forward)

(defadvice
isearch-repeat-forward
(after isearch-repeat-forward-recenter activate)
(recenter))
(ad-activate 'isearch-repeat-forward)

(defadvice
isearch-repeat-backward
(after isearch-repeat-backward-recenter activate)
(recenter))
(ad-activate 'isearch-repeat-backward); recenter after search
(defadvice
isearch-forward
(after isearch-forward-recenter activate)
(recenter))
(ad-activate 'isearch-forward)

(defadvice
isearch-repeat-forward
(after isearch-repeat-forward-recenter activate)
(recenter))
(ad-activate 'isearch-repeat-forward)

(defadvice
isearch-repeat-backward
(after isearch-repeat-backward-recenter activate)
(recenter))
(ad-activate 'isearch-repeat-backward)

; so can quit using ESC
(defun minibuffer-keyboard-quit ()
"Abort recursive edit.
In Delete Selection mode, if the mark is active, just deactivate it;
then it takes a second [keyboard-quit] to abort the minibuffer."
(interactive)
(if (and delete-selection-mode transient-mark-mode mark-active)
(setq deactivate-mark t)
(when (get-buffer "Completions") (delete-windows-on "Completions"))
(abort-recursive-edit)))

;(define-key evil-normal-state-map [escape] 'keyboard-quit)
;(define-key evil-visual-state-map [escape] 'keyboard-quit)
;(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
;(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
;(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
;(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
;(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)

;auto-indent with return key
(define-key global-map (kbd "RET") 'newline-and-indent)

;spaces instead of tabs
(setq-default tab-width 2 indent-tabs-mode nil)

(set-default-font "Inconsolata 13")
;(set-face-attribute 'default nil :height 130)

(setq auto-save-default 1) ; must be non-nil to be on
(setq auto-save-interval 40) ; in characters
(setq auto-save-timeout 5) ; how many secs of idle time

;; ;; automatically save buffers associated with files on buffer switch
;; ;; and on windows switch
;; (defadvice switch-to-buffer (before save-buffer-now activate)
;; (when buffer-file-name (save-buffer)))
;; (defadvice other-window (before other-window-now activate)
;; (when buffer-file-name (save-buffer)))
;; (defadvice windmove-up (before other-window-now activate)
;; (when buffer-file-name (save-buffer)))
;; (defadvice windmove-down (before other-window-now activate)
;; (when buffer-file-name (save-buffer)))
;; (defadvice windmove-left (before other-window-now activate)
;; (when buffer-file-name (save-buffer)))
;; (defadvice windmove-right (before other-window-now activate)
;; (when buffer-file-name (save-buffer)))

;session management
(desktop-save-mode 1)

; define with-eval-after-load if not defined by emacs (needed for emacs <=24.3)
(unless (fboundp 'with-eval-after-load)
(defmacro with-eval-after-load (file &rest body)
(declare (indent 1) (debug t))
`(eval-after-load ,file '(progn ,@Body))))

(with-eval-after-load "persp-mode-autoloads"
(setq wg-morph-on nil) ;; switch off animation of restoring window configuration
(add-hook 'after-init-hook #'(lambda () (persp-mode 1))))

;; remember cursor position of files when reopening them
(setq save-place-file "~/.emacs.d/saveplace")
(setq-default save-place t)
(require 'saveplace)

;; save history of all things
;; from http://www.wisdomandwonder.com/wordpress/wp-content/uploads/2014/03/C3F.html
(setq savehist-file "~/.emacs.d/savehist")
(setq savehist-save-minibuffer-history 1)
(setq savehist-additional-variables
'(kill-ring
search-ring
regexp-search-ring))
(savehist-mode 1)

;move autosave and backup files to the tmp directory
(setq backup-directory-alist
((".*" . ,"~/.emacs.d/backups"))) ; you can see where emacs is doing it with M-x describe-variable temporary-file-directory (setq auto-save-file-name-transforms ((".*" ,"~/.emacs.d/auto-save-list" t)))

(setq visible-bell t)

;; don't move cursor back one position when leaving insert mode
(setq evil-move-cursor-back nil)

(column-number-mode)
(diminish 'visual-line-mode)
(eval-after-load 'undo-tree '(diminish 'undo-tree-mode))
;(eval-after-load 'auto-complete '(diminish 'auto-complete-mode))
(eval-after-load 'projectile '(diminish 'projectile-mode))
(eval-after-load "yasnippet" '(diminish 'yas-minor-mode))
(eval-after-load 'magit '(diminish 'magit-auto-revert-mode))

(defun my-split-window-horizontally ()
(interactive)
(split-window-horizontally)
(evil-window-right 1))

(evil-leader/set-key "cv" 'delete-other-windows)

(evil-leader/set-key "=" (lambda(begin end) ; = align selection lines by "="
(interactive "r")
(align-regexp begin end "(\s-*)=" 1 1 )))

;(evil-leader/set-key "v" (lambda () (interactive)
; (split-window-horizontally)
; (evil-window-right 1)))

;; (evil-leader/set-key "p" (lambda() ; paste on a new line below current
;; (interactive)
;; (evil-open-below 1)
;; (evil-paste-after 1)
;; (evil-normal-state)))
;; (evil-leader/set-key "P" (lambda() ; paste on a new line below current
;; (interactive)
;; (evil-open-above 1)
;; (evil-previous-visual-line 1)
;; (evil-paste-after 1)
;; (evil-normal-state)))
;; (evil-leader/set-key "o" (lambda () ; o open line below
;; (interactive)
;; (evil-open-below 1)
;; (evil-normal-state)))
;; (evil-leader/set-key "O" (lambda () ; o open line below
;; (interactive)
;; (evil-open-above 1)
;; (evil-normal-state)))

;; reload tags files without asking
;; commented this out b/c it was weirdly opening the tags buffer while I was doing other stuff...
;(setq tags-revert-without-query 1)

(defun insert-date ()
"Insert current date yyyy-mm-dd."
(interactive)
(when (use-region-p)
(delete-region (region-beginning) (region-end) )
)
(insert (format-time-string "%Y-%m-%d"))
)

(defun insert-date-time ()
"Insert current date-time string in full
ISO 8601 format.
Example: 2010-11-29T23:23:35-08:00
See: URL `http://en.wikipedia.org/wiki/ISO_8601'
"
(interactive)
(when (use-region-p)
(delete-region (region-beginning) (region-end) )
)
(insert
(concat
(format-time-string "%Y-%m-%dT%T")
((lambda (x) (concat (substring x 0 3) ":" (substring x 3 5)))
(format-time-string "%z")))))

;; configure evil-matchit
(global-evil-matchit-mode 1)

(defun my-align-hashmarks (p1 p2)
(interactive "r")
(align-regexp p1 p2 "(\s-*)#" 1 1 nil))

(defun generate-riffer-ctags ()
(interactive)
(shell-command "ctags -e -R --exclude=deps -f ~/Documents/playthink/code/riffer3/tags ~/Documents/playthink/code/riffer3"))

; better names for same-named buffers

(defun switch-to-previous-buffer ()
"Switch to previously open buffer.
Repeated invocations toggle between the two most recently open buffers."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) 1)))

; open a browser on a url
;from http://francesco-cek.com/open-an-url-in-safari-from-emacs/
(setq browse-url-browser-function 'browse-url-generic)
(setq browse-url-generic-program "open")

; show the time in the mode line
(display-time-mode 1)
(setq display-time-format "%l:%M%p")

; answer y/n to questions in the minibuffer
(fset 'yes-or-no-p 'y-or-n-p)

; make mini-windows grow as neccesary
(setq resize-mini-windows t)

;;ORG-MODE
(setq org-directory "/org")
(setq org-default-notes-file "
/org/refile.org")

(setq org-startup-indented t)
(setq org-hide-leading-stars t)
(setq org-return-follows-link t) ; this setting doesn't seem to work
(add-to-list 'load-path (expand-file-name "/org-mode/lisp"))
(add-to-list 'auto-mode-alist '(".(org|org_archive|txt)$" . org-mode))
(setq org-agenda-files (quote ( "
/org" "~/Documents/playthink/code/node_riffer")))

(setq org-tag-alist '(("riffer" . ?r) ("journal" . ?j) ("key" . ?k)))

(setq org-export-ascii-links-to-notes t)

; todo stats include subtrees
(setq org-hierarchical-todo-statistics nil)

(setq org-todo-keywords (quote ((type "mike(m)" "rick(r)" "some(s)" "discuss(d)" "|" "DONE(d)")
(sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "PHONE" "MEETING"))))

(setq org-todo-keyword-faces
(quote (("mike" :foreground "red" :weight bold)
("rick" :foreground "orange" :weight bold)
("some" :foreground "pink" :weight bold)
("discuss" :foreground "red" :weight bold)
("DONE" :foreground "forest green" :weight bold)
("WAITING" :foreground "yellow" :weight bold)
("HOLD" :foreground "blue" :weight bold)
("CANCELLED" :foreground "forest green" :weight bold)
("PHONE" :foreground "forest green" :weight bold)
("MEETING" :foreground "forest green" :weight bold)
)))

(setq org-use-fast-todo-selection t)
(setq org-treat-S-cursor-todo-selection-as-state-change nil) ; allow S-left and S-right to cycle through states without setting timestamps and entering notes - just fix up the status of the entry

;; I have a few triggers that automatically assign tags to tasks based on state changes. If a task moves to CANCELLED state then it gets a CANCELLED tag. Moving a CANCELLED task back to TODO removes the CANCELLED tag. These are used for filtering tasks in agenda views which I'll talk about later.

;; The triggers break down to the following rules:

;; Moving a task to CANCELLED adds a CANCELLED tag
;; Moving a task to WAITING adds a WAITING tag
;; Moving a task to HOLD adds WAITING and HOLD tags
;; Moving a task to a done state removes WAITING and HOLD tags
;; Moving a task to mike, rick, or some removes WAITING, CANCELLED, and HOLD tags
;; Moving a task to NEXT removes WAITING, CANCELLED, and HOLD tags
;; Moving a task to DONE removes WAITING, CANCELLED, and HOLD tags

(setq org-todo-state-tags-triggers
(quote (("CANCELLED" ("CANCELLED" . t))
("WAITING" ("WAITING" . t))
("HOLD" ("WAITING") ("HOLD" . t))
("mike" ("WAITING") ("CANCELLED") ("HOLD"))
("rick" ("WAITING") ("CANCELLED") ("HOLD"))
("discuss" ("WAITING") ("CANCELLED") ("HOLD"))
("some" ("WAITING") ("CANCELLED") ("HOLD"))
("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))

;; org-capture
;; Capture templates for: TODO tasks, Notes, appointments, phone calls, meetings, and org-protocol
(setq org-capture-templates
(quote (("t" "todo" entry (file "/org/refile.org")
"* some %? :noexport:\n%U\n%a\n" )
("r" "respond" entry (file "
/org/refile.org")
"* NEXT Respond to %:from on %:subject\nSCHEDULED: %t\n%U\n%a\n" :clock-in t :clock-resume t :immediate-finish t)
("n" "note" entry (file "/org/xnotes.org") ; NOTE I tried to use an inherited tag for the whole file, but agenda keyword searches don't find inherited keywords
"* %? :NOTE:\n%U\n\n")
("j" "Journal" entry (file+datetree "
/org/diary.org")
"* %?\n%U\n")
("w" "org-protocol" entry (file "/org/refile.org")
"* TODO Review %c\n%U\n" :immediate-finish t)
("m" "Meeting" entry (file "
/org/refile.org")
"* MEETING with %? :MEETING:\n%U")
("p" "Phone call" entry (file "/org/refile.org")
"* PHONE %? :PHONE:\n%U")
("h" "Habit" entry (file "
/org/refile.org")
"* NEXT %?\n%U\n%a\nSCHEDULED: %(format-time-string "<%Y-%m-%d %a .+1d/3d>")\n:PROPERTIES:\n:STYLE: habit\n:REPEAT_TO_STATE: NEXT\n:END:\n"))))

;; refiling
; targets include this file and any file contributing to the agenda - up to 9 levels deep
(setq org-refile-targets (quote ((nil :maxlevel . 9)
(org-agenda-files :maxlevel . 9))))

; use full outline paths for refile targets
(setq org-refile-use-outline-path t)

; complete directly...
(setq org-outline-path-complete-in-steps nil)

;; patch to complete refilings using helm
; http://comments.gmane.org/gmane.emacs.orgmode/87651
(when (and (boundp 'org-completion-handler)
(require 'helm nil t))
(defun org-helm-completion-handler
(prompt collection &optional predicate require-match
initial-input hist def inherit-input-method)
(helm-comp-read prompt
collection
;; the character \ is filtered out by default ;(
:fc-transformer nil
:test predicate
:must-match require-match
:initial-input initial-input
:history hist
:default def))

  (setq org-completion-handler 'org-helm-completion-handler))

;; end patch

; allow refile to create parent tasks with confirmation
(setq org-refile-allow-creating-parent-nodes (quote confirm))

;; Remove empty LOGBOOK drawers on clock out
;;http://doc.norang.ca/org-mode.html#TasksAndState
;; I GET ERRORS WHEN I TRY TO FINISH CAPTURE WHEN THIS IS UNCOMMENTED
;; (defun bh/remove-empty-drawer-on-clock-out ()
;; (interactive)
;; (save-excursion
;; (beginning-of-line 0)
;; (org-remove-empty-drawer-at (point))))
;; (add-hook 'org-clock-out-hook 'bh/remove-empty-drawer-on-clock-out 'append)

;; Custom agenda command definitions
(setq org-agenda-custom-commands
(quote (("N" "Notes" tags "NOTE"
((org-agenda-overriding-header "Notes")
(org-tags-match-list-sublevels t)))
)))

;; END ORGMODE

(defun close-and-kill-next-pane ()
"If there are multiple windows, then close the other pane and kill the buffer in it also."
(interactive)
(other-window 1)
(kill-this-buffer)
(if (not (one-window-p))
(delete-window)))

(setq framemove-hook-into-windmove t)

(defun set-truncate-lines ()
"Toggle value of truncate-lines and refresh window display."
(interactive)
(setq truncate-lines (not truncate-lines))
;; now refresh window display (an idiom from simple.el):
(save-excursion
(set-window-start (selected-window)
(window-start (selected-window)))))

;; javascript
(add-hook 'js-mode-hook 'js2-minor-mode)
(add-hook 'js-mode-hook 'ac-js2-mode)
(setq js-indent-level 2)

(defun my-paredit-nonlisp ()
"Turn on paredit mode for non-lisps."
(interactive)
(set (make-local-variable 'paredit-space-for-delimiter-predicates)
'((lambda (endp delimiter) nil)))
(paredit-mode 1))

;; (add-hook 'js-mode-hook 'my-paredit-nonlisp) ; turn on paredit for javascript

; make mouse and trackpad scrolling work better
(setq mouse-wheel-follow-mouse 't)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1)))

(add-to-list 'load-path "~/Documents/playthink/code/tern/emacs/")
(autoload 'tern-mode "tern.el" nil t)

; NOTE I disabled auto-complete in favor of company mode, so 'tern-auto-complete might not work anymore
; 'tern-auto-complete was trying to load auto-complete, which I uninstalled b/c Alchemist uses company mode
(add-hook 'js-mode-hook (lambda () (tern-mode t)))
;; (eval-after-load 'tern
;; '(progn
;; (require 'tern-auto-complete)
;; (tern-ac-setup)))

; call this if Tern doesn't auto-reload changed files. Tern will restart itself
(defun delete-tern-process ()
(interactive)
(delete-process "Tern"))

;from https://atlanis.net/blog/posts/nodejs-repl-eval.html
;;; nodejs-repl-eval.el --- Summary
;;; Commentary:
;;;
;;; Evaluation functions for the `nodejs-repl' package. Written on a stormy
;;; night between days of node hacking.
;;;
;;; Code:

(require 'js2-mode)
(require 'nodejs-repl)

(defun nodejs-repl-eval-region (start end)
"Evaluate the region specified by START' andEND'."
(let ((proc (get-process nodejs-repl-process-name)))
(comint-simple-send proc (buffer-substring-no-properties start end))))

(defun nodejs-repl-eval-node (node)
"Evaluate NODE', ajs2-mode' node."
(let ((beg (js2-node-abs-pos node))
(end (js2-node-abs-end node)))
(nodejs-repl-eval-region beg end)))

(defun nodejs-repl--find-current-or-prev-node (pos &optional include-comments)
"Locate the first node before `POS'. Return a node or nil.

If `INCLUDE-COMMENTS' is set to t, then comments are considered
valid nodes. This is stupid, don't do it."
(let ((node (js2-node-at-point pos (not include-comments))))
(if (or (null node)
(js2-ast-root-p node))
(unless (= 0 pos)
(nodejs-repl--find-current-or-prev-node (1- pos) include-comments))
node)))

(defun nodejs-repl-eval-function ()
"Evaluate the current or previous function."
(interactive)
(let* ((fn-above-node (lambda (node)
(js2-mode-function-at-point (js2-node-abs-pos node))))
(fn (funcall fn-above-node
(nodejs-repl--find-current-or-prev-node
(point) (lambda (node)
(not (null (funcall fn-above-node node))))))))
(unless (null fn)
(nodejs-repl-eval-node fn))))

(defun nodejs-repl-eval-first-stmt (pos)
"Evaluate the first statement found from POS' byjs2-mode'.

If this statement is a block statement, its first parent
statement is found. This will be either a function declaration,
function call, or assignment statement."
(let ((node (js2-mode-find-first-stmt (nodejs-repl--find-current-or-prev-node pos))))
(cond
((js2-block-node-p node) (nodejs-repl-eval-node (js2-node-parent-stmt node)))
((not (null node)) (nodejs-repl-eval-node node)))))

(defun nodejs-repl-eval-dwim ()
"Heuristic evaluation of JS code in a NodeJS repl.

Evaluates the region, if active, or the first statement found at
or prior to the point.

If the point is at the end of a line, evaluation is done from one
character prior. In many cases, this will be a semicolon and will
change what is evaluated to the statement on the current line."
(interactive)
(cond
((use-region-p) (nodejs-repl-eval-region (region-beginning) (region-end)))
((= (line-end-position) (point)) (nodejs-repl-eval-first-stmt (1- (point))))
(t (nodejs-repl-eval-first-stmt (point)))))

(defun nodejs-repl-eval-buffer (&optional buffer)
"Evaluate the current buffer or the one given as `BUFFER'.

`BUFFER' should be a string or buffer."
(interactive)
(let ((buffer (or buffer (current-buffer))))
(with-current-buffer buffer
(nodejs-repl-eval-region (point-min) (point-max)))))

(provide 'nodejs-repl-eval)

;;; nodejs-repl-eval.el ends here

;; web mode for html files
(add-to-list 'auto-mode-alist '(".html?'" . web-mode))

(defun my-web-mode-hook ()
"Hooks for Web mode."
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
)

(add-hook 'web-mode-hook 'my-web-mode-hook)

(electric-pair-mode 1)

; highlight the line the cursor is on
(global-hl-line-mode 1)

; show matching parens
(require 'paren)

;(set-face-background 'show-paren-match (face-background 'default))
;(set-face-foreground 'show-paren-match "#def")
;(set-face-attribute 'show-paren-match nil :weight 'extra-bold)
(setq show-paren-style 'mixed) ; mixed = highlight expression parenthesis = highlight only parens
(show-paren-mode 1)
(show-paren-delay 0) ;this should be AFTER 'mixed (above), or mixed style doesn't start reliably

; utility functions from spacemacs
(defun spacemacs/last-buffer ()
"Switch back and forth between current and last buffer."
(interactive)
(switch-to-buffer (other-buffer (current-buffer) t)))

; from spacemacs
;; from magnars
(defun delete-current-buffer-file ()
"Removes file connected to current buffer and kills buffer."
(interactive)
(let ((filename (buffer-file-name))
(buffer (current-buffer))
(name (buffer-name)))
(if (not (and filename (file-exists-p filename)))
(ido-kill-buffer)
(when (yes-or-no-p "Are you sure you want to delete this file? ")
(delete-file filename t)
(kill-buffer buffer)
(message "File '%s' successfully removed" filename)))))

(defun spacemacs/safe-revert-buffer ()
"Prompt before reverting the file."
(interactive)
(revert-buffer nil nil))

(defun spacemacs/safe-erase-buffer ()
"Prompt before erasing the content of the file."
(interactive)
(if (y-or-n-p (format "Erase content of buffer %s ? " (current-buffer)))
(erase-buffer)))

from alchemist.el.

tonini avatar tonini commented on July 22, 2024

Could you please require elixir-mode and then alchemist specific like:

(require `elixir-mode)
(require `alchemist)

And then I would like to ask do you try to complete Modules from your own project outside of the Module you try to complete? I mean it can't be that the completion works for your own code but not for elixir core, thats not possible. It sounds more that the completion not working at all.

Please try to require the elixir-mode and alchemist as displayed on top.

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

Before adding the require lines you've asked, I did the other thing you asked, to try completion between my modules.

From my Riffer4 module I typed:
AWS
and I got the suggestion AWSDBInterface (another of my modules), which I selected.

I then got to:
AWSDBInterface.get
and got the suggestion get_AWS_credentials_from_local_file (one of my functions)

So it seems completion IS working between my modules...

I then added the require's you asked for and restarted emacs. It made no difference. If I type
List.dup
I get no suggestions.

Best.

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

More information that might be relevent:

When I'm typing into one of my modules in (.../code/Riffer4), then if another project (root .../code/Riffer3) of mine doesn't have its TAGS file loaded into emacs, it somehow automatically gets loaded and switched to. Very bizarre.

In an attempt to figure out what the heck was going on, I deleted that tags file. Now when I edit in my current project, I get the following error message:

Company: Back-end (company-dabbrev-code company-gtags company-etags company-keywords) error "File .../code/riffer3/TAGS does not exist" with args (candidates Riffe)

I can understand why Company would need a tags file for my riffer4 project (which currently does not exist, by the way), but why in heck is it wanting a tags file for another project, none of whose files are even loaded into emacs?

I'm thinking this might have something to do with your company-backend, somehow?

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

OK, I solved the riffer3 baloney. The emacs variable tags-table-list was set to the wrong value. I fixed that and now company doesn't try to use the wrong tags file.

However, there is still no completion for Elixir library functions.

Best.

from alchemist.el.

tonini avatar tonini commented on July 22, 2024

Ok it looks like we found the problem.

Please try this custom hook to set the only company- backend to be alchemist-company in the list.

(defun custom-alchemist-hook ()
  (set (make-local-variable 'company-backends) '(alchemist-company)))

(add-hook 'alchemist-mode-hook  'custom-alchemist-hook)

The completion only for your own codebase works because your company-mode only works with ctags, and thats not how alchemist works. I think there is an issue in your company-mode setup where the priority of the backend from ctags is higher than the alchemist-company one, so your ctags entries working but not alchemist-company at all.

Please try this.

Thanks

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

I added that code to init.el and restarted emacs.

Unfortunately it didn't solve the problem

Thanks for trying...

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

... actually, in addition to not solving the problem, that set of code prevented company from doing any kind of completion at all :(

Sigh!

from alchemist.el.

tonini avatar tonini commented on July 22, 2024

hi @fremontmj

actually, in addition to not solving the problem, that set of code prevented company from doing any kind of completion at all :(

Actually thats great, because now we know that alchemist-company doesn't work at all, and the completion you got inside your own codebase was just because of the ctags.

To clear none of you custom emacs setups is the problem why its not working you need to remove everything out of your emacs init except the elixir and alchemist stuff.

Also run the shell-command function from inside emacs with the following command: elixir --version

Thanks

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

elixir --version reports Elixir 1.0.2

My init.el now looks like this:

;;; package --- Summary
;;; Commentary:
;;; Code:
;;; all above here just to get flycheck to shut the hell up

(add-to-list 'load-path "/.emacs.d/.cask/24.4.1/elpa/elixir-mode-20150103.439")
(add-to-list 'load-path "
/.emacs.d/.cask/24.4.1/elpa/alchemist-20150109.106")
(add-to-list 'load-path "~/.emacs.d/.cask/24.4.1/elpa/company-20150112.906")
(require elixir-mode) (requirealchemist)
(require `company)
; company package (company-mode)
; alchemist uses company mode rather than auto-complete
(add-hook 'after-init-hook 'global-company-mode)
(setq alchemist-project-compile-when-needed t)

... and no change in functionality: it will complete my functions but not Elixir library functions.

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

(those require's are actually on separate lines and have backticks, somehow the cut/paste messed up)

from alchemist.el.

tonini avatar tonini commented on July 22, 2024

You using (setq alchemist-project-compile-when-needed t) which means that it compile your project also when try to complete. When your project is not compile able, (for example issues in the code) the completion wont work.

Please try to use back-ticks for including code, so it will be correct formatted and its much more readable.

Please just do the following inside your init.el

(require 'cask "/usr/local/Cellar/cask/0.7.2/cask.el")
(cask-initialize)

(global-company-mode 1)

(require 'elixir-mode)
(require 'alchemist)

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

OK, I implemented your init.el exactly, but nothing changed.

I'm no emacs expert, but doesn't your version of init.el still load all of the packages managed by Cask? For instance, after starting emacs with your init.el, I was able to run a helm command even though helm is not mentioned in the init.el (but it is in my Cask file and installed .cask directory).

That's why I had previously tried this init.el, which doesn't use Cask:

(add-to-list 'load-path "/.emacs.d/.cask/24.4.1/elpa/elixir-mode-20150103.439")
(add-to-list 'load-path "
/.emacs.d/.cask/24.4.1/elpa/alchemist-20150109.106")
(add-to-list 'load-path "~/.emacs.d/.cask/24.4.1/elpa/company-20150112.906")
(require 'elixir-mode)
(require 'alchemist)
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)

from alchemist.el.

tonini avatar tonini commented on July 22, 2024

ok an updated one :)

(add-to-list 'load-path "~/.emacs.d/.cask/24.4.1/elpa/elixir-mode-20150103.439")
(add-to-list 'load-path "~/.emacs.d/.cask/24.4.1/elpa/alchemist-20150109.106")
(add-to-list 'load-path "~/.emacs.d/.cask/24.4.1/elpa/company-20150112.906")

(global-company-mode 1)
(require 'elixir-mode)
(require 'alchemist)

alchemist will require company for you.

from alchemist.el.

playfulThinking avatar playfulThinking commented on July 22, 2024

I get "symbol's function definition is void: global-company-mode" unless I put

(require 'company) before
(global-company-mode 1)

Probably b/c we're trying to set a mode before Alchemist required company. :)

In any case, no change, even with the additional require :(

from alchemist.el.

iensu avatar iensu commented on July 22, 2024

Hi! I also just installed alchemist and elixir-mode, and they're working great. Awesome job.

However, I was having an issue with displaying documentation during autocompletion. The reason was that I had enabled alchemist-project-compile-when-needed. After disabling it, documentation lookup works fine again. The clue was in your comment above. Maybe add a line about that in the readme?

Thanks

from alchemist.el.

tonini avatar tonini commented on July 22, 2024

Thanks @iensu

I know I need to refine the README and also fix some grammar things. :-)

Thanks for the feedback.

Cheers

from alchemist.el.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.