(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))
(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)))))
(defun my-php-format-gnu ()
"Formats php code the gnu way."
(interactive)
(replace-regexp "\\([a-zA-Z0-9]\\)(" "\\1 (" nil (point-min) (point-max))
(replace-regexp "\\([a-zA-Z0-9()]\\) \*{$" "\\1\n{" nil (point-min) (point-max))
(replace-regexp "^ \*} \*\\([a-zA-Z0-9()]\\)" "}\n\\1" nil (point-min) (point-max))
(replace-string "select count (*)" "select count(*)" nil (point-min) (point-max))
(replace-string "now ()" "now()" nil (point-min) (point-max))
(indent-region (point-min) (point-max)))
(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))))
(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))))
(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)))
(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)