Skip to content

Instantly share code, notes, and snippets.

Heikki Lehvaslaiho heikkil

Block or report user

Report or block heikkil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@heikkil
heikkil / org-duplicate-heading.el
Last active Mar 17, 2019
Report org headings with duplicate names in the *Messages* buffer. Reveal them and move to the last duplicate. Run after saving the buffer.
View org-duplicate-heading.el
(require 'dash)
(defun org-duplicate-heading ()
"Move to duplicate heading in the current org buffer."
(interactive)
(let ((header-list '()))
(org-element-map (org-element-parse-buffer) 'headline
(lambda (x)
(let ((header (org-element-property :raw-value x))
(begin (org-element-property :begin x)))
(when (-contains? header-list header)
@heikkil
heikkil / org-clock-merge.el
Last active Mar 4, 2019
Merge the org CLOCK line with the next CLOCK line
View org-clock-merge.el
(defun org-clock-merge (arg)
"Merge the org CLOCK line with the next CLOCK line.
Requires that the time ranges in two lines overlap, i.e. the
start time of the first line and the second time of the second
line are identical.
If the testing fails, move the cursor one line down.
Universal argument ARG overrides the test and merges
@heikkil
heikkil / fill-or-unfill.el
Created Aug 28, 2018
Version of #'endless/fill-or-unfill and key bindings that work in org-mode
View fill-or-unfill.el
(defun endless/fill-or-unfill ()
"Like `fill-paragraph', but unfill if used twice."
(interactive)
(let ((fill-column
(if (eq last-command #'endless/fill-or-unfill)
(progn (setq this-command nil)
(point-max))
fill-column)))
(if (eq major-mode 'org-mode)
(call-interactively #' org-fill-paragraph)
@heikkil
heikkil / raw_copy
Created Feb 4, 2016
copy raw images corresponding to jpgs in a subdir into an other subdir
View raw_copy
#!/usr/bin/env perl
use Modern::Perl;
use File::Find;
use Getopt::Long;
use constant PROGRAMME_NAME => 'raw_copy';
use constant VERSION => '0.2';
GetOptions(
'v|version' => sub{ print PROGRAMME_NAME, ", version ", VERSION, "\n";
@heikkil
heikkil / orphan_raw
Created Feb 4, 2016
delete raw image files without matching jpgs in the same directory
View orphan_raw
#!/usr/bin/env perl
use Modern::Perl;
use File::Find;
use Getopt::Long;
use constant PROGRAMME_NAME => 'orphan_raw';
use constant VERSION => '0.2';
GetOptions(
'v|version' => sub{ print PROGRAMME_NAME, ", version ", VERSION, "\n";
@heikkil
heikkil / feh-remove.sh
Last active Feb 16, 2017
Action script for feh to remove the current image
View feh-remove.sh
#!/bin/sh
# ~/bin/feh-remove.sh
DIR=`dirname "$1"`
if [ ! -d $DIR/removed ]; then
mkdir $DIR/removed
fi;
mv "$1" $DIR/removed
@heikkil
heikkil / feh-copy.sh
Last active Feb 16, 2017
Action script for feh to create a copy of the current image
View feh-copy.sh
#!/bin/sh
# ~/bin/feh-copy.sh
DIR=`dirname "$1"`
if [ ! -d $DIR/copied ]; then
mkdir $DIR/copied
fi;
cp "$1" $DIR/copied
@heikkil
heikkil / counsel-yank-fish-history.el
Created Jan 29, 2016
Search fish history using ivy mode
View counsel-yank-fish-history.el
;; mod from http://blog.binchen.org/posts/use-ivy-mode-to-search-bash-history.html
(require 'dash)
(defun counsel-yank-fish-history ()
"Yank the fish history"
(interactive)
(let (hist-cmd collection val)
(shell-command "history -r") ; reload history
(setq collection
(nreverse
(split-string (with-temp-buffer (insert-file-contents (file-truename "~/.config/fish/fish_history"))
@heikkil
heikkil / elfeed-link-and-note
Last active Nov 5, 2016
Elfeed configuration for emacs focusing on functions and bindings to copy and link to web pages
View elfeed-link-and-note
View gist:d79445c345e55e3cc3b5
"
_c_enter _q_uote _e_macs-lisp _L_aTeX:
_l_atex _e_xample _p_erl _i_ndex:
_a_scii _v_erse _P_erl tangled _I_NCLUDE:
_s_rc ^ ^ plant_u_ml _H_TML:
_h_tml ^ ^ ^ ^ _A_SCII:
"
("e" (progn (hot-expand "<s") (insert "emacs-lisp") (forward-line)))
("p" (progn (hot-expand "<s") (insert "perl") (forward-line)))
You can’t perform that action at this time.