Klimi's new dotfiles with stow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.7 KiB

5 years ago
  1. (require 'pulse)
  2. ;;(setq next-error-hook nil)
  3. (add-hook 'next-error-hook
  4. '(lambda ()
  5. (if (ycmd-next-error-at-ycmd-button (point)) (push-button)
  6. (let ((compilation-buffer (get-buffer "*compilation*")))
  7. (when compilation-buffer
  8. (save-excursion
  9. (set-buffer "*compilation*")
  10. (move-beginning-of-line nil)
  11. (pulse-line-hook-function)))))))
  12. (eval-after-load "ycmd"
  13. '(add-hook 'ycmd-mode-hook
  14. '(lambda ()
  15. (setq next-error-function 'ycmd-next-error-goto-next-error))))
  16. (defun ycmd-next-error-at-ycmd-button (cur)
  17. "Returns whether CUR is at a ycmd button."
  18. (let* ((button (button-at cur))
  19. (type (and button (button-type button))))
  20. (or (eq type 'ycmd--error-button)
  21. (eq type 'ycmd--warning-button))))
  22. (defun ycmd-next-error-goto-next-error (&optional count reset)
  23. "Go to next YCM-detected error in the current buffer, or stay put if none"
  24. (interactive)
  25. (when (null count) (setq count 0))
  26. (let ((target nil)
  27. (move-fn (if (< count 0) 'previous-button 'next-button))
  28. (next-count (if (< count -1) (1+ count) (if (> count 1) (1- count) 0)))
  29. (cur (if reset (point-min) (point))))
  30. (save-excursion
  31. (when (and
  32. (setq cur (funcall (symbol-function move-fn) cur))
  33. (ycmd-next-error-at-ycmd-button cur))
  34. (setq target cur)))
  35. (if (not (and count target))
  36. (message "Reached last error")
  37. (goto-char target)
  38. (when (not (eq next-count 0))
  39. (ycmd-next-error-goto-next-error next-count nil)))))
  40. (provide 'ycmd-next-error)