I'm trying to implement GTD in emacs based on http://members.optusnet.com.au/~charles57/GTD/gtd_workflow.html and I have a problem with refiling.
In the file .emacs I have such a configuration
(setq org-refile-use-outline-path 'file)
'(org-refile-targets (quote (("gtd.org" :maxlevel . 1) ("done.org" :level . 1))))
The sequence Cc Cw can select only the place of the current file:
gtd.org/
gtd.org/tasks
gtd.org/projects
Please help in determining why do not I move to done.org
Regards
Krzysiek
Here's a fix of your code:
(setq org-refile-targets
'(("gtd.org" :maxlevel . 1)
("done.org" :maxlevel . 1)))
Here's a setup similar to what I use now:
(setq org-agenda-files
'("gtd.org" "done.org"))
(setq org-refile-targets
'((nil :maxlevel . 3)
(org-agenda-files :maxlevel . 3)))
This first element of org-refile-targets decides the heading levels to consider
within current file, the second element - within other agenda files.
Related
I have set c-basic-offset & c-basic-indent to 4 expecting it to indent newlines after brackets only in C/C++ files. But the issue I'm facing is every newline in ".txt" document is taking 4 spaces by default which I don't want.
Here is my init.el file
(global-display-line-numbers-mode 1)
(set-frame-font "JetBrains Mono-11" nil t)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
(setq c-basic-offset 4)
(setq c-basic-indent 4)
;(setq-default c-basic-offset 4)
;(c-set-offset 'substatement-open 0)
; stop creating backup files
(setq make-backup-files nil)
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(setq recentf-max-saved-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
;; start the initial frame maximized
(add-to-list 'initial-frame-alist '(fullscreen . maximized))
;; start every frame maximized
(add-to-list 'default-frame-alist '(fullscreen . maximized))
Please help me get rid of 4 space characters in a normal text file.
You can make your settings specific for mode. In your case if you want indentation settings to apply only for C/C++ files, you need to apply these settings for that mode hook. There are various ways of doing it, one of them is using defining those settings in a defun and add that defun to appropriate hook.
Example below shows to setup c-basic-offset and c-basic-indent to 4.
(defun my-c-mode-common-hook ()
;; my customizations for all of c-mode and related modes
(setq c-basic-offset 4)
(setq c-basic-indent 4)
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
These are the setting in my .emacs for refiling in org-mode:
(setq org-refile-targets (quote ((nil :maxlevel . 10)
(org-agenda-files :maxlevel . 10))))
(setq org-refile-use-outline-path t)
(setq org-outline-path-complete-in-steps nil)
(setq org-refile-allow-creating-parent-nodes (quote confirm))
Refiling to an existing path works as it should but I can't create a new node and refile to that as the last line should allow me to do. When I refile to a path like:
Existing node"/New node"
I get the error:
Please save the buffer to a file before refiling
Supposedly this means that emacs can figure out the target file but the target is set with the org-refile-targets line so what's wrong?
This is related to this question:
how-to-have-emacs-helm-list-offer-files-in-current-directory-as-options
but rather than add files from the current directory, I'd like to be able to have a fixed list of directories that helm-mini would always offer the files from. Ideally, I would like to be able to just have the files with a particular extension, and I'd like this to be done recursively (only one layer deep, in fact).
Here is a slightly different take that prefilters for the org extension.
(require 'helm-cmd-t)
(defvar my-org-folders (list "~/org")
"my permanent folders for helm-mini")
(defun helm-my-org (&optional arg)
"Use C-u arg to work with repos."
(interactive "P")
(if (consp arg)
(call-interactively 'helm-cmd-t-repos)
(let ((helm-ff-transformer-show-only-basename nil))
(helm :sources (mapcar (lambda (dir)
(helm-cmd-t-get-create-source-dir dir))
my-org-folders)
:candidate-number-limit 20
:buffer "*helm-my-org:*"
:input "org$ "))))
You can better solve it by leveraging the helm-cmd-t library. It packages
a directory recursively as repositories that you can use as a source.
It understands how to read lots of DVCS repos very fast.
The default functionality is not exactly what you are after here, but you can
easily leverage the machinery to fill all your requirements.
For example, here I define a command that adds two repos to the default
helm-mini sources.
(require 'helm-cmd-t)
(defvar my-mini-folders (list "~/src/ember/data" "~/src/ember/ember.js")
"my permanent folders for helm-mini")
(defun helm-my-mini (&optional arg)
"my helm-mini. Use C-u arg to work with repos."
(interactive "P")
(if (consp arg)
(call-interactively 'helm-cmd-t-repos)
(let ((helm-ff-transformer-show-only-basename nil))
(helm :sources (nconc (list
helm-c-source-buffers-list
helm-c-source-recentf
helm-c-source-buffer-not-found)
(mapcar (lambda (dir)
(helm-cmd-t-get-create-source-dir dir))
my-mini-folders))
:candidate-number-limit 20
:buffer "*helm-my-mini:*"))))
Here you go. I am using this code to list all org files in a particular directory. If you want to list all the files, just remove the candidate-transformer line in the source, and remove the emagician/helm-ct-is-org-file.
You'll likely want to rename the source/variable/function too. ;)
edit: Fixed, thanks to peeking at helm-cmd-t
note: This is my first real crack at making a helm source, and this implementation likely sucks. It also specifically solves my problem (finding all org files in one directly only) rather then the more generalized problem (building a helm source based on files from a particular directory).
(defvar emagician/helm-c-source-files
`((name . "Find Emagician Files")
(header-name . (lambda (_)))
(candidates . ,(lambda ()
(when (file-accessible-directory-p emagician-dir)
(directory-files emagician-dir t))))
(match helm-c-match-on-file-name helm-c-match-on-directory-name)
(keymap . ,helm-generic-files-map)
(candidate-transformer . emagician/helm-ct-is-org-file)
(help-message . helm-generic-file-help-message)
(mode-line . ,helm-generic-file-mode-line-string)
(type . file)))
(defun emagician/helm-ct-is-org-file (candidates)
(remove-if-not (lambda (c)
(and (string= (substring c -4) ".org")
(not (string= (substring (file-name-nondirectory c) 0 2) ".#"))))
candidates))
(defun emagician/helm-emagician-dir ()
"List all the org files in the Emagician dir"
(interactive)
(helm :sources emagician/helm-c-source-files
:candidate-number-limit 40
:buffer "*emagician-|-+-|-files*"))
(global-set-key (kbd "S-<f3>") 'emagician/helm-emagician-dir)
I have a long list of files and file extensions which I would like to have Emacs open automatically in ruby-mode. From using Google, the most basic solution that works is this:
(setq auto-mode-alist (cons '("\.rake$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\.thor$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("Gemfile$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("Rakefile$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("Crushfile$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("Capfile$" . ruby-mode) auto-mode-alist))
Which seems way repetitive to me. Is there a way I could define the list of pairs once and either loop or cons it directly onto auto-mode-alist? I've tried
(cons '(("\\.rake" . ruby-mode)
("\\.thor" . ruby-mode)) auto-mode-alist)
but that doesn't seem to work. Any suggestions?
You only need a single regexp (and hence entry in auto-mode-alist) to match all those options, and you can let regexp-opt do the work of building it for you.
(let* ((ruby-files '(".rake" ".thor" "Gemfile" "Rakefile" "Crushfile" "Capfile"))
(ruby-regexp (concat (regexp-opt ruby-files t) "\\'")))
(add-to-list 'auto-mode-alist (cons ruby-regexp 'ruby-mode)))
If you especially want individual entries, you might do something like this:
(mapc
(lambda (file)
(add-to-list 'auto-mode-alist
(cons (concat (regexp-quote file) "\\'") 'ruby-mode)))
'(".rake" ".thor" "Gemfile" "Rakefile" "Crushfile" "Capfile"))
cons takes an item and a list and returns a new list with that item at the head. (for example (cons 1 '(2 3)) gives '(1 2 3))
What you want to do is take a list and a list and append them together
(setq auto-mode-alist
(append '(("\\.rake" . ruby-mode)
("\\.thor" . ruby-mode))
auto-mode-alist))
My favorite would be
(push '("\\(\\.\\(rake\\|thor\\)\\|\\(Gem\\|Rake\\|Crush\\|Cap\\)file\\)\\'" . ruby-mode) auto-mode-alist)
I'm trying out http://emacspeak.sourceforge.net now that I have it running on windows. I'd like to use emacs as more than a plain text editor and was wondering what extensions/packages everyone can't live with out? The languages I use the most are Perl, Java, and some C/C++.
There is a pretty terrific initial setup in the EMACS Starter Kit. If you like working with plain text, look at Org-Mode. And by all means, explore the EMACS Wiki.
I like color theme and of course the modes for the languages I'm using.
I like being able to make my editor behave exactly as I want it. Consequently, I've written a bunch of packages to do tweak things to within an inch of their lives. I'll list a few at the bottom of the post. Standard packages I'd have trouble living without would include:
gnus
tnt - AOL IM client (which I help to maintain)
jabber
git-emacs
camel-case
swbuff (and my swbuff-advice extension)
dired
And here are some that I wrote that I could never, ever live without (which is why I wrote them):
whole-line-or-region - cut and paste the whole line when region is not defined
cua-lite - a lite-weight CUA package
dired-single - restrict dired to a single, reusable buffer
hobo - tramp replacement, not quite ready for prime-time
Also, as Charlie mentions, just peruse EmacsWiki whenever you get bored. You'll always find something new to try. And I read gnu.emacs.sources to see the latest and greatest that people have to offer.
some bits from my overly-large .emacs file:
(setq inhibit-startup-message t)
;; window maximized
(when (fboundp 'w32-send-sys-command)
(w32-send-sys-command #xf030))
;; http://www.emacswiki.org/cgi-bin/wiki/DiredPlus
(load "dired+")
(load "w32-browser") ;; open file on current line (etc.)
;; dired stuff to open files a la Windows from Howard Melman
(defun dired-execute-file (&optional arg)
(interactive "P")
(mapcar #'(lambda (file)
(w32-shell-execute "open" (convert-standard-filename file)))
(dired-get-marked-files nil arg)))
(defun dired-mouse-execute-file (event)
"In dired, execute the file or goto directory name you click on."
(interactive "e")
(set-buffer (window-buffer (posn-window (event-end event))))
(goto-char (posn-point (event-end event)))
(if (file-directory-p (dired-get-filename))
(dired-find-file)
(dired-execute-file)))
(global-set-key [?\C-x mouse-2] 'dired-mouse-execute-file)
;; push current-line onto kill-ring
;; http://www.dotemacs.de/dotfiles/SteveMolitor.emacs.html
(defun push-line ()
"Select current line, push onto kill ring."
(interactive)
(save-excursion
(copy-region-as-kill (re-search-backward "^") (re-search-forward "$"))))
(global-set-key "\C-cp" 'push-line)
;; default groups for ibuffer
;; http://www.shellarchive.co.uk/content/emacs_tips.html#sec17
(setq ibuffer-saved-filter-groups
(quote (("default"
("dired" (mode . dired-mode))
("perl" (mode . cperl-mode))
("java" (mode . java-mode))
("planner" (or
(name . "^\\*Calendar\\*$")
(name . "diary")))
("emacs" (or
(mode . help-mode)
(mode . occur-mode)
(mode . Info-mode)
(mode . bookmark-bmenu-mode)
(name . "^\\*Apropos\\*$")
(name . "^.emacs$")
(name . "el$")
(name . "^\\*scratch\\*$")
(name . "^\\*Messages\\*$")
(name . "^\\*Completions\\*$")))
("vb" (or
(mode . visual-basic-mode)
(mode . vb-project)))
("BugTracker" (name . ".*btnet.*"))
("gnus" (or
(mode . message-mode)
(mode . bbdb-mode)
(mode . mail-mode)
(mode . gnus-group-mode)
(mode . gnus-summary-mode)
(mode . gnus-article-mode)
(name . "^\\.bbdb$")
(name . "^\\.newsrc-dribble")))))))
;; ibuffer, I like my buffers to be grouped
(add-hook 'ibuffer-mode-hook
(lambda ()
(ibuffer-switch-to-saved-filter-groups
"default")))
;; http://www.emacswiki.org/cgi-bin/wiki/CPerlMode
;; http://www.khngai.com/emacs/perl.php
;; Use cperl-mode instead of the default perl-mode
(add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
;; daily-tip (or whenever Emacs is launched)
;; http://emacs.wordpress.com/2007/06/21/tip-of-the-day/
(defun totd ()
(interactive)
(random t) ;; seed with time-of-day
(with-output-to-temp-buffer "*Tip of the day*"
(let* ((commands (loop for s being the symbols
when (commandp s) collect s))
(command (nth (random (length commands)) commands)))
(princ
(concat "Your tip for the day is:\n"
"========================\n\n"
(describe-function command)
"\n\nInvoke with:\n\n"
(with-temp-buffer
(where-is command t)
(buffer-string)))))))
;; swap slashes and backslashes in current line -- useful for converting paths to be Windows-readable
;;http://www.xsteve.at/prg/emacs/.emacs.txt
(defun xsteve-exchange-slash-and-backslash ()
"Exchanges / with \ and in the current line or in the region when a region-mark is active."
(interactive)
(save-match-data
(save-excursion
(let ((replace-count 0)
(eol-pos (if mark-active (region-end) (progn (end-of-line) (point))))
(bol-pos (if mark-active (region-beginning) (progn (beginning-of-line) (point)))))
(goto-char bol-pos)
(while (re-search-forward "/\\|\\\\" eol-pos t)
(setq replace-count (+ replace-count 1))
(cond ((string-equal (match-string 0) "/") (replace-match "\\\\" nil nil))
((string-equal (match-string 0) "\\") (replace-match "/" nil nil)))
(message (format "%d changes made." replace-count)))))))
(global-set-key (kbd "M-\\") 'xsteve-exchange-slash-and-backslash)
Check out: dotfiles.org/.emacs
EmacsWiki: Category DotEmacs
SO: What's in YOUR .emacs?
some other packages not referenced above:
Elscreen -
W3m (emacs-friendly text-based browser)