      (let* ((git-toplevel (string-trim-right
 			   (shell-command-to-string
 			    "git rev-parse --show-toplevel 2>/dev/null")))
-	    (git-p (not (string-empty-p git-toplevel))))
-       (when git-p
-	 (setq default-directory git-toplevel))
+	    (git-p (not (string-empty-p git-toplevel)))
+	    (default-directory (if git-p git-toplevel default-directory)))
        (list (read-shell-command "Run: "
 				 (if git-p
 				     "git --no-pager grep -nHE "


(with-eval-after-load "counsel"
  ;; XXX Workaround for https://github.com/abo-abo/swiper/issues/866
  (defun counsel-git-grep-function (string &optional _pred &rest _unused)
    "Grep in the current git repository for STRING."
    (if (and (or counsel-git-grep-skip-counting-lines
		 (> counsel--git-grep-count 20000))
	     (< (length string) 3))
	(counsel-more-chars 3)
      (let* ((string (car (split-string string "\n" t))) ; XXX Modify `string'
	     (default-directory counsel--git-dir)
	     (cmd (format counsel-git-grep-cmd
			  (setq ivy--old-re (ivy--regex string t)))))
	(if (and (not counsel-git-grep-skip-counting-lines)
		 (<= counsel--git-grep-count 20000))
	    (split-string (shell-command-to-string cmd) "\n" t)
	  (counsel--gg-candidates (ivy--regex string))
	  nil)))))

(when (require 'avy nil 'noerror)
  (setq avy-all-windows 'all-frames)

(global-set-key (kbd "C-c H") 'hl-line-mode)
(when (fboundp 'column-highlight-mode)
  (global-set-key (kbd "C-c h") 'column-highlight-mode))

;; ;;; Disable italic font style in comments and documentation.
;; (set-face-italic 'font-lock-comment-face nil)
;; (set-face-italic 'font-lock-doc-face nil)

(custom-set-variables
