al-misc-cmd.el 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ;;; al-misc-cmd.el --- Miscellaneous interactive commands
  2. ;; Copyright © 2013-2016 Alex Kost
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ;;; Code:
  14. (require 'org)
  15. ;;;###autoload
  16. (defun al/next-link (&optional search-backward)
  17. "Go to the next link."
  18. ;; The function is almost the same as `org-next-link'.
  19. (interactive)
  20. (when (and org-link-search-failed
  21. (eq this-command last-command))
  22. (goto-char (point-min))
  23. (message "Link search wrapped back to beginning of buffer"))
  24. (setq org-link-search-failed nil)
  25. (let* ((pos (point))
  26. (srch-fun (if search-backward
  27. 're-search-backward
  28. 're-search-forward)))
  29. (when (looking-at org-any-link-re)
  30. ;; Don't stay stuck at link without an org-link face.
  31. (forward-char (if search-backward -1 1)))
  32. (if (funcall srch-fun org-any-link-re nil t)
  33. (progn
  34. (goto-char (match-beginning 0))
  35. (if (outline-invisible-p) (org-show-context)))
  36. (goto-char pos)
  37. (setq org-link-search-failed t)
  38. (message "No further link found"))))
  39. ;;;###autoload
  40. (defun al/previous-link ()
  41. "Go to the previous link."
  42. (interactive)
  43. (al/next-link t))
  44. ;;;###autoload
  45. (defun al/create-tags (shell-cmd)
  46. "Create tags file using shell command SHELL-CMD.
  47. Interactively prompt for shell command.
  48. With prefix, prompt for directory as well."
  49. (interactive
  50. (let ((dir (if current-prefix-arg
  51. (read-directory-name "Root tags directory: ")
  52. "")))
  53. (list (read-shell-command
  54. "Shell command for generating tags: "
  55. (format "find %s -type f -name '*.[ch]' | etags -" dir)))))
  56. (eshell-command shell-cmd))
  57. ;; Idea from <http://www.emacswiki.org/emacs-en/DisabledCommands>.
  58. ;;;###autoload
  59. (defun al/show-disabled-commands ()
  60. "Show all disabled commands."
  61. (interactive)
  62. (with-output-to-temp-buffer "*Disabled commands*"
  63. (mapatoms (lambda (symbol)
  64. (when (get symbol 'disabled)
  65. (prin1 symbol)
  66. (princ "\n"))))))
  67. ;;;###autoload
  68. (defun al/refontify (&rest _)
  69. "Refontify the current buffer."
  70. (jit-lock-refontify))
  71. ;;; Spelling and languages
  72. ;;;###autoload
  73. (defun al/set-isearch-input-method (input-method)
  74. "Activate input method INPUT-METHOD in interactive search.
  75. See `set-input-method' for details."
  76. (set-input-method input-method)
  77. (setq isearch-input-method-function input-method-function)
  78. (isearch-update))
  79. (provide 'al-misc-cmd)
  80. ;;; al-misc-cmd.el ends here