info.el 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. (defun info-colors-fontify-reference-items ()
  2. "Fontify reference items in an `info' node."
  3. (goto-char (point-min))
  4. (while (re-search-forward
  5. (concat "^ --? \
  6. \\("
  7. (mapconcat 'identity '("Command"
  8. "Constant"
  9. "C Function"
  10. "Function"
  11. "Scheme Procedure"
  12. "Scheme Syntax"
  13. "Scheme System"
  14. "Scheme Variable"
  15. "Monadic Procedure"
  16. "Macro"
  17. "Special Form"
  18. "Syntax"
  19. "Syntax class"
  20. "User Option"
  21. "Variable")
  22. "\\|")
  23. "\\):\
  24. *\\(\\S-+\\)\
  25. \\(\\( .*\\)?\\([\n] \\{8\\}.*\\)*\\)")
  26. nil t)
  27. (let ((sym (intern (match-string 1))))
  28. (put-text-property (match-beginning 1) (match-end 1)
  29. 'font-lock-face 'info-colors-ref-item-type)
  30. (put-text-property
  31. (match-beginning 2) (match-end 2)
  32. 'font-lock-face (case sym
  33. ('Constant 'info-colors-ref-item-constant)
  34. ('Variable 'info-colors-ref-item-variable)
  35. ('User\ Option 'info-colors-ref-item-user-option)
  36. ('Special\ Form 'info-colors-ref-item-special-form)
  37. ('Macro 'info-colors-ref-item-macro)
  38. ('Monadic\ Procedure 'info-colors-ref-item-function)
  39. ('Scheme\ Procedure 'info-colors-ref-item-syntax-class)
  40. ('Scheme\ Syntax 'info-colors-ref-item-syntax-class)
  41. ('Function 'info-colors-ref-item-function)
  42. ('Command 'info-colors-ref-item-command)
  43. ('Syntax\ class 'info-colors-ref-item-syntax-class)))
  44. (when (match-beginning 3)
  45. (put-text-property (match-beginning 3) (match-end 3)
  46. 'font-lock-face 'info-colors-ref-item-other)))))
  47. ;; Origin <https://github.com/alezost/guix.el/pull/9#issuecomment-340556583>.
  48. (with-eval-after-load 'info
  49. (info-initialize)
  50. (setq Info-directory-list
  51. (append (wi-expand-file-names
  52. '("/home/oleg/src/git.savannah.gnu.org/git/guix/doc"
  53. "~/.guix-profile.d/gdb/share/info"
  54. "~/.guix-profile.d/autotools/share/info"))
  55. Info-directory-list)))
  56. ;;
  57. ;; Alternative: <https://lists.gnu.org/archive/html/help-guix/2017-03/msg00140.html>,
  58. ;; see <.bashrc>.
  59. (add-hook 'Info-selection-hook 'info-colors-fontify-node)