(not (tramp-tramp-file-p (buffer-file-name (current-buffer))))
2013-01-22
How to determine if current buffer is tramp buffer in Emacs
Tramp is Emacs' way to access remote files, e.g. via SSH. To determine if the current buffer is accessing a tramp file (e.g. to not try to run gtags or similar), try this:
2013-01-08
Quoting a set of parameters for program arguments using sed
I have a script which launches another program. That program takes some command line arguments, which in turn can have parameters. Those parameters may include ";", which has a special meaning in the Bash. To quote these, you can use the following sed command:
$ echo "foo --bar=1 --baz=2" | sed -e 's/\(--[^[:space:]]*=\)\([^[:space:]]*\)/\1"\2"/g' foo --bar="1" --baz="2"
2012-10-30
Counting Color Pages in PDF Files
Printing books and such in color can be expensive. So here is how to count the color pages using a recent version of GhostScript and a UNIX shell:
gs -o - -sDEVICE=inkcov input.pdf | grep -v "^ 0.00000 0.00000 0.00000" | grep "^ " | wc -l
2012-10-29
Improved handling of background GNU Global update
Earlier this year I detailed how to run gtags of GNU Global when Emacs is idle. However, this collides with some special Emacs modes, like ediff. That mode makes its own Emacs frame layout, which can be destroyed by the xgtags incremental update buffer. So I conceived a way to disable gtags temporarily as long as ediff is active:
;; This stuff is only needed, if you haven't got xgtags loaded yet
(autoload 'gtags-mode "gtags" "" t)
(require 'xgtags)
(add-hook 'c-mode-common-hook (lambda () (xgtags-mode 1)))
(defun global-update-incrementally () (shell-command "global -u -q" "*Messages*" "*Messages*") )
;; Call gtags update when idle for some time
(defcustom my-gtags-update-idle-time 60
"Number of idle seconds before an incremental gtags update is launched"
:group 'my-group
:type 'integer
)
;; initially allow gtags updates
(setq my-gtags-update-active t)
(run-with-idle-timer my-gtags-update-idle-time t
(lambda ()
(if (and my-gtags-update-active
(not (minibufferp) )
)
(progn
(message "Running gtags...")
(global-update-incrementally)
)
)
)
)
(add-hook 'ediff-quit-hook
(lambda ()
(message "Activating gtags update.")
(setq my-gtags-update-active t)
)
)
(add-hook 'ediff-before-setup-hook
(lambda ()
(message "Deactivating gtags update.")
(setq my-gtags-update-active nil)
)
)
2012-09-28
Encode image sequence to MPEG4 video
Today something very simple: use ffmpeg to encode an image sequence as a MPEG4 video:
ffmpeg -f image2 -i filename-%04d.png -vcodec mpeg4 -b 6000k output.mp4
I often use blender or custom software to render out a bunch of images. Blender usually names output files filename-0000.png, where 0000 is the frame number. So ffmpeg can generate those filenames with the usual printf style format. You can of course tweak ffmpeg's output via a myriad of options. But this here will simply generate a 25fps mpeg4 file, which is easily embedded for example into your Keynote presentation. On OS X you can get ffmpeg for example via MacPorts: sudo port install ffmpeg, and Linux distros usually have a package for ffmpeg as well.
ffmpeg -f image2 -i filename-%04d.png -vcodec mpeg4 -b 6000k output.mp4
I often use blender or custom software to render out a bunch of images. Blender usually names output files filename-0000.png, where 0000 is the frame number. So ffmpeg can generate those filenames with the usual printf style format. You can of course tweak ffmpeg's output via a myriad of options. But this here will simply generate a 25fps mpeg4 file, which is easily embedded for example into your Keynote presentation. On OS X you can get ffmpeg for example via MacPorts: sudo port install ffmpeg, and Linux distros usually have a package for ffmpeg as well.
2012-09-08
Using Ctrl+Arrow keys in the OS X terminal
The key combination Ctrl + left or right arrow key can be used to go a word left or right in many programs such as GNU Emacs or the bash. In the default configuration of the OS X terminal, this is not the case. That's because Terminal.app sends the wrong key codes for bash's default configuration. So you just need to got to the preferences (cmd+,) and set the key codes for Ctrl+left and right to \033b and \033f respectively:
2012-08-31
Java Autocompletion for Emacs
The past few weeks I have been using the great eclim, and the corresponding emacs-eclim package. It allows you to use many of Eclipse's features in your favourite editor. The installation of emacs-eclim is rather easy, and the one for eclim is even easier, since it comes with a simple clickety-click-installer.
I use emacs-eclim for Java development, and it works rather well. I use the two functions ac-complete-emacs-eclim and ac-complete-eclim-c-dot for auto-completion, which is the most important aspect when using such heavily object oriented languages and when developing large projects. Also useful are the functions eclim-java-import-missing, and eclim-java-remove-unused-imports. The current project can be compiled by calling eclim-project-build.
In theory, you can also use eclim with CDT for C++ development and auto-completion, but I rather stick with my earlier clang based solution, which is very fast and accurate.
I use emacs-eclim for Java development, and it works rather well. I use the two functions ac-complete-emacs-eclim and ac-complete-eclim-c-dot for auto-completion, which is the most important aspect when using such heavily object oriented languages and when developing large projects. Also useful are the functions eclim-java-import-missing, and eclim-java-remove-unused-imports. The current project can be compiled by calling eclim-project-build.
In theory, you can also use eclim with CDT for C++ development and auto-completion, but I rather stick with my earlier clang based solution, which is very fast and accurate.
Subscribe to:
Comments (Atom)