Helm has builtin helm-mini command which includes buffers and recentf in its sources.
(setq helm-source-buffers-list
(helm-make-source "Buffers" 'helm-source-buffers)))
(helm :sources helm-mini-default-sources
:buffer "*helm mini*"
:truncate-lines t)
There is one more package helm recent dirs which provides helm interface to recentd
It uses '(helm-source-dired-recent-dirs) as it source.
I am trying to combine those two so i am adding this in helm-mini
(append helm-mini-default-sources '(helm-source-dired-recent-dirs))
but it doesn't work. Am I missing something?
The append form doesn't change the value of helm-mini-default-sources, so it, i.e., M-x helm-mini, does not work. You can combine setq and append or just add-to-list:
(setq helm-mini-default-sources
(append helm-mini-default-sources'(helm-source-dired-recent-dirs)))
;; or
(add-to-list 'helm-mini-default-sources 'helm-source-dired-recent-dirs 'append)
but the more flexible way is just using a plain setq because you can choose source and their order:
(setq helm-mini-default-sources '(helm-source-buffers-list
helm-source-dired-recent-dirs
helm-source-recentf
helm-source-buffer-not-found))
There is no needs to write your own helm-mini function, use the built-in one is enough.
Related
Sorry for my poor English.
I'm configuring my emacs with erlang flymake. Source files in src's nested folders report 'can't find include file', but files in src/folder can find the include file.
My emacs settings for erlang:
;; erlang-mode
(setq load-path (cons "/usr/local/Cellar/erlang/R15B02/lib/erlang/lib/tools-2.6.8/emacs" load-path))
(setq erlang-root-dir "/usr/local/Cellar/erlang/R15B02/lib/erlang")
(setq exec-path (cons "/usr/local/Cellar/erlang/R15B02/lib/erlang/bin" exec-path))
(require 'erlang-start)
;; distel
(add-to-list 'load-path "/usr/local/share/distel/elisp/")
(require 'distel)
(distel-setup)
;; erlang-flymake
(require 'erlang-flymake)
(erlang-flymake-only-on-save)
My erlang application folder is like following:
app/src/ (source code)
src/mod
src/lib
app/include/ (hrls)
app/ebin/ (compiled code)
...etc
In erlang-flymake there are 2 variables (erlang-flymake-get-include-dirs-function and erlang-flymake-get-code-path-dirs-function), that specify functions to search include & ebin directories. Right now, they're pointing to the functions erlang-flymake-get-include-dirs and erlang-flymake-get-code-path-dirs that simply return current dir + include and ebin correspondingly. For example, you can use following code to do this:
(defun get-erlang-app-dir ()
(let* ((src-path (file-name-directory (buffer-file-name)))
(pos (string-match "/src/" src-path)))
(if pos
(substring src-path 0 (+ 1 pos))
src-path)))
(setq erlang-flymake-get-code-path-dirs-function
(lambda ()
(concat (get-erlang-app-dir) "ebin")))
(setq erlang-flymake-get-code-include-dirs-function
(lambda ()
(concat (get-erlang-app-dir) "include")))
P.S. Are you using rebar to maintain your project?
If you use erlang-flymake you might want to look at https://github.com/ten0s/syntaxerl. It's a syntax checker for Erlang. It uses erlang-flymake under the hood, but instead of `erlc' it uses a custom syntax checker that can evaluate .erl, .hrl, .config, .rel, .app, .app.src, .escript files. The syntax checker is rebar aware, but also works with standard Erlang/OTP directory structure. Emacs's setup is also there.
I would like emacs to use the current buffer's file name as part of the command passed to M-x compile. For example, if I am editing ~/foo.rb, I would like M-x compile to execute ruby ~/foo.rb
I tried setting compilation-command to (list "ruby" buffer-file-name), but apparently you can't pass an s-expression here.
1. Read the documentation of the function
C-hfcompileRET
compile is an interactive autoloaded compiled Lisp function in
`compile.el'.
[snip]
Interactively, prompts for the command if `compilation-read-command' is
non-nil; otherwise uses `compile-command'. With prefix arg, always prompts.
Additionally, with universal prefix arg, compilation buffer will be in
comint mode, i.e. interactive.
Now that we've found what we were looking for, let's …
2. … read the documentation of the variable …
C-hvcompile-commandRET
compile-command is a variable defined in `compile.el'.
Its value is "make -k "
[snip]
Sometimes it is useful for files to supply local values for this variable.
You might also use mode hooks to specify it in certain modes, like this:
(add-hook 'c-mode-hook
(lambda ()
(unless (or (file-exists-p "makefile")
(file-exists-p "Makefile"))
(set (make-local-variable 'compile-command)
(concat "make -k "
(file-name-sans-extension buffer-file-name))))))
3. … and finally adapt the example to your needs
(add-hook 'ruby-mode-hook
(lambda ()
(set (make-local-variable 'compile-command)
(concat "ruby " buffer-file-name))))
Of course you can easily customize it to use rake if there is a
Rakefile.
I have a directory tasks/ in org-agenda-files variable. When i add a file to org-agenda-files variable through C-c [ command (org-agenda-file-to-front), the directory path is replaced by paths of the files, that are currently in that directory. It is bad, because when i add some files to tasks/ later on, they will not contribute to my agenda.
Is there some way to avoid this, or i'm stuck with manually adding files and directories to org-agenda-files?
This problem is acknowledged at Org Mode - Organize Your Life In Plain Text!
Emacs version: 24.0.50.1
Org-mode version: 7.8.09
You could define a command that just adds a file to org-agenda-files without calling org-agenda-files-to-front, and then rebing that to C-c [. For example:
(defun my-org-agenda-file-to-front ()
(interactive)
(setq org-agenda-files (append org-agenda-files (list (buffer-file-name (current-buffer))))))
(define-key org-mode-map (kbd "C-c [") `my-org-agenda-file-to-front)
Here is my try:
(if (eq system-type 'gnu/linux)
(load "/usr/share/emacs/site-lisp/site-gentoo")
(require 'site-gentoo))
But anyways I receive error on windows :
/.emacs':
File error: Cannot open load file, site-gentoo
Your problem is in the way you use if: its documentation says it's
(if COND THEN ELSE...)
I.e. your (require 'site-gentoo) gets executed if and only if it's not a GNU/Linux system.
Use when instead, that should do what you intend.
Also, there should actually no need to use both load and require, their usage should have the same result. The differences are mostly that require will search the load-path and don't load something again that was already loaded before.
It should be:
(if (eq system-type 'gnu/linux)
(progn
(load "/usr/share/emacs/site-lisp/site-gentoo")
(require 'site-gentoo)))
or
(when (eq system-type 'gnu/linux)
(load "/usr/share/emacs/site-lisp/site-gentoo")
(require 'site-gentoo))
Instead of (load "/usr/share/emacs/site-lisp/site-gentoo") you should add the folder containing the load file to the load-path:
(add-to-list 'load-path "/usr/share/emacs/site-lisp/")
That should do the trick. require only works for files on the load-path, load on the other hand simply evaluates the lisp file it was given as parameter.
Rörd and Bozhidar Batsov have already provided the answer as to how to resolve it, but just to add in the reason why your original code was failing.
(if COND THEN ELSE...) only accepts a single THEN command. To be able to have it evaluate multiple commands when it returns true you have to wrap the commands in (progn BODY...).
Your code was stating:
If on linux: (load "/usr/share/emacs/site-lisp/site-gentoo")
If not on linux: (require 'site-gentoo)
Using (when ...) or wrapping in (progn ...) will both provide the desired solution.
I would like to see examples of how to setup perforce, using the config file functionality where emacs is used as the diff and merge programs (P4DIFF and P4MERGE settings). Even better if this is on Windows.
I'm also struggling with getting the P4EDITOR to work correctly when using emacsclientw, specifically specifying the alternate-editor functionality.
Any tips, suggestions, example configs are very welcome.
Here's a different trick I used to use. It adds a few command line options to emacs so that you can do diffs and merges in a new emacs instance (again using ediff).
;; -diff
(defun command-line-diff (switch)
(let ((file1 (pop command-line-args-left))
(file2 (pop command-line-args-left)))
(ediff file1 file2)))
(add-to-list 'command-switch-alist '("-diff" . command-line-diff))
;; -merge
(defun command-line-merge (switch)
(let ((base (pop command-line-args-left))
(sccs (pop command-line-args-left))
(mine (pop command-line-args-left))
(merg (pop command-line-args-left)))
(ediff-merge-with-ancestor sccs mine base () merg)))
(add-to-list 'command-switch-alist '("-merge" . command-line-merge))
Just put that in your .emacs file. Then you can set your P4DIFF program to be emacs -diff and your P4MERGE program to be emacs -merge.
I'm assuming you're already using p4.el.
Here's a function that will allow you to set your p4-client-config easily:
(defun p4-go (config)
(interactive
(list (read-file-name "P4 Config file: "
(concat (getenv "HOME") "/etc/perforce/")
""
t)))
(p4-set-client-config (expand-file-name config))
t)
Then I just run M-x p4-go <RET> conf <RET>.
My ~/etc/perforce/conf file looks like:
P4CLIENT=ewarmenhoven-ppd
P4PORT=perforce.netflix.com:1666
P4USER=ewarmenhoven
P4EDITOR=emacsclient
P4DIFF=diff -dupU8
P4MERGE=~/bin/emerge
The emerge merge program is just a short little shell script that calls emacsclient appropriately:
#!/bin/bash
base=$1
sccs=$2
mine=$3
merg=$4
emacsclient -e "(ediff-merge-files-with-ancestor \"$base\" \"$sccs\" \"$mine\" () \"$merg\")"
emacsclient "$merg"
If you're using cygwin it should work just fine.
For doing diffs, if it's running from the shell then I want the output in the shell, hence just using normal diff. If it's not, I use p4-ediff, which is bound to C-x p - by default.
The awesome answer by Eric doesn't work properly in latest emacs because of welcome screen. In order to hide the welcome screen (so that you may get the diff properly) please refer Unable to hide welcome screen in Emacs.
Another nifty setting which opens the diff in regular vertical mode is setting the below config variable
(custom-set-variables
;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
;; Your init file should contain only one such instance.
'(ediff-split-window-function (quote split-window-horizontally)))