I'm working with large, extra wide data files I probably should just be viewing in Excel... but I'd rather stay in Emacs. Is there an elisp function to search (and fontify) just on the current line?
Isearch is quite flexible and if you become tired of constantly narrowing the buffer (as was suggested), you may want to have a dedicated command for this, e.g.
(defun isearch-line-forward (&optional regexp-p) (interactive "P") (let* ((beg (line-beginning-position)) (end (line-end-position)) (isearch-message-prefix-add "[Line]") (isearch-search-fun-function `(lambda () (lambda (string &optional bound noerror) (save-restriction (narrow-to-region ,beg ,end) (funcall (isearch-search-fun-default) string bound noerror)))))) (isearch-forward regexp-p)))
- Select the current line (
C-a C-SPC C-e)
- Narrow region (
C-x n n)
- Perform search using any method
- Go back to the original buffer by widening (
C-x n w)