Float modeemacsStatus area
;; (Download)
;; An exercise in interactive completion (defun my-ssh (host) (interactive (list (let ((completion-ignore-case t)) (ido-completing-read "ssh: " (list "daedalus" "shodan"))))) (start-process "my-ssh" nil "urxvt" "-e" "ssh" host))
;; Synchronise the current directory with its associated apache directory ;; using Unison (defun my-htdocs-unison () (interactive) (dolist (directory my-projects) (let ((current-key (car directory)) (current-value (cdr directory))) (if (string-match current-value default-directory) (call-process "sudo" nil nil nil "-H" "/usr/bin/unison" current-key)))))
;; Formats php code the gnu way (defun my-php-format-gnu () "Formats php code the gnu way." (interactive)
;; this ensures that all opening brackets are preceded with a space (replace-regexp "\\([a-zA-Z0-9]\\)(" "\\1 (" nil (point-min) (point-max))
;; this ensures that opening braces have lines to themselves (replace-regexp "\\([a-zA-Z0-9()]\\) \*{$" "\\1\n{" nil (point-min) (point-max))
;; this ensures that closing braces have lines to themselves (replace-regexp "^ \*} \*\\([a-zA-Z0-9()]\\)" "}\n\\1" nil (point-min) (point-max))
;; make sure we haven't messed up any SQL statements (replace-string "select count (*)" "select count(*)" nil (point-min) (point-max)) (replace-string "now ()" "now()" nil (point-min) (point-max))
;; re-do the indentation (indent-region (point-min) (point-max)))
;; Count the number of words in the current buffer print a message in the ;; minibuffer with the result. (defun count-words-buffer () "Count the number of words in the current buffer; print a message in the minibuffer with the result." (interactive) (let ((count 0)) (save-excursion (goto-char (point-min)) (while (< (point) (point-max)) (forward-word 1) (setq count (1+ count))) (message "buffer contains %d words." count))))
;; Toggle between VBNET & HTML mode. (defun my-toggle-asp-mode () (interactive) "Toggle mode between VBNET & HTML modes" (cond ((string-match "^XHTML" mode-name) (vbnet-mode)) ((string-match "^Visual Basic .NET" mode-name) (html-mode))))
;; Increment or decrement to the number at the point, handy for macros (defun my-increment-number-at-point (arg) (interactive "P") (skip-chars-backward "0123456789") (or (looking-at "[0123456789]+") (error "No number at point")) (if arg (setq new-number (1- (string-to-number (match-string 0)))) (setq new-number (1+ (string-to-number (match-string 0))))) (replace-match (number-to-string new-number)))
;; Opens the current file or directory as root (defun my-visit-as-root () (interactive) (setq regexp "^/su::") (if buffer-file-name (let ((file (replace-regexp-in-string "^~" "/home/mat" buffer-file-name))) (if (string-match regexp file) (message "Already visiting as root.") (progn (kill-buffer (current-buffer)) (find-file (concat "/su::" file))))) (if dired-directory (let ((directory (replace-regexp-in-string "^~" "/home/mat" dired-directory))) (if (string-match regexp directory) (message "Already visiting as root.") (progn (kill-buffer (current-buffer)) (dired (concat "/su::" directory))))) (message "Not visiting a file or directory."))))
(provide 'my-miscellaneous)



:-- my-miscellaneous.el All (1,0) (Emacs-Lisp/lah)

% Bookmark
_ ________



















:%* *Bookmark List* All (6,0) (Bookmark Menu)