Skip to content

Instantly share code, notes, and snippets.

@t1anchen
Last active December 19, 2015 04:08
Show Gist options
  • Save t1anchen/5894618 to your computer and use it in GitHub Desktop.
Save t1anchen/5894618 to your computer and use it in GitHub Desktop.
emacs handy functions
(defun insert-textual-timestamp-in-diary ()
;; Set timestamp insert function. This function comes from
;; http://www.patd.net/~ciggieposeur/other/startup.el
;; RFC 3339 and ISO 8601
(interactive "*")
(insert
(concat "["
(format-time-string "%Y-%m-%dT%T%z" (current-time))
"] ")))
(global-set-key (kbd "C-c 1 `") 'insert-textual-timestamp-in-diary)
(setq scroll-step 1) ; Scroll step 1 line per time
;; Toggle truncated lines: M-x toggle-truncate-lines
;; This is a BufferLocalVariable.
;; Or it's available to be changed when loading .emacs
(set-default 'truncate-lines t)
(defun unfill-paragraph ()
"Takes a multi-line paragraph and makes it into a single line of text."
(interactive)
(let ((fill-column (point-max)))
(fill-paragraph nil)))
(defun unfill-region (beg end)
"Unfill the region, joining text paragraphs into a single
logical line. This is useful, e.g., for use with
`visual-line-mode'."
(interactive "*r")
(let ((fill-column (point-max)))
(fill-region beg end)))
(defun unwrap-line ()
"Remove all newlines until we get to two consecutive ones.
Or until we reach the end of the buffer.
Great for unwrapping quotes before sending them on IRC."
(interactive)
(let ((start (point))
(end (copy-marker (or (search-forward "\n\n" nil t)
(point-max))))
(fill-column (point-max)))
(fill-region start end)
(goto-char end)
(newline)
(goto-char start)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment