Skip to main content
Adapt @clemera 's suggestion
Source Link
Stefan
  • 26.7k
  • 3
  • 52
  • 88

An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.

Something as straightforward like this can help you:

(defun occur-kill-line()
  "Quick and dirty discard line from occur resultset. (from
from https://emacs.stackexchange.com/a/52865/13589)"13589"
  (interactive)
  (let ((bufferinhibit-read-only nilt))
    (kill-whole-line)
    (delete-blank-lines)))

invoking this function will kill the current line in occur buffer. Pressing g will revert the buffer.

Adding this:

(define-key occur-mode-map (kbd "k") 'occur-kill-line)

will bind k to occur-kill-line to occur-mode-map making it available as occur command just pressing k.

An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.

Something as straightforward like this can help you:

(defun occur-kill-line()
  "Quick and dirty discard line from occur resultset. (from
https://emacs.stackexchange.com/a/52865/13589)"
  (interactive)
  (let ((buffer-read-only nil))
    (kill-whole-line)
    (delete-blank-lines)))

invoking this function will kill the current line in occur buffer. Pressing g will revert the buffer.

Adding this:

(define-key occur-mode-map (kbd "k") 'occur-kill-line)

will bind k to occur-kill-line to occur-mode-map making it available as occur command just pressing k.

An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.

Something as straightforward like this can help you:

(defun occur-kill-line()
  "Quick and dirty discard line from occur resultset.
from https://emacs.stackexchange.com/a/52865/13589"
  (interactive)
  (let ((inhibit-read-only t))
    (kill-whole-line)
    (delete-blank-lines)))

invoking this function will kill the current line in occur buffer. Pressing g will revert the buffer.

Adding this:

(define-key occur-mode-map (kbd "k") 'occur-kill-line)

will bind k to occur-kill-line to occur-mode-map making it available as occur command just pressing k.

An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.

Something as straightforward like this can help you:

(defun occur-kill-line()
    "Quick and dirty discard line from occur resultset. (from
https://emacs.stackexchange.com/a/52865/13589)"
    (interactive)
   (let ((buffer-read-only-mode -1nil))
    (kill-whole-line)(delete-blank-lines)
    (readdelete-onlyblank-mode +1lines)))

invoking this function will kill the current line in occur buffer. Pressing g will revert the buffer.

Adding this:

(define-key occur-mode-map (kbd "k") 'occur-kill-line)

will bind k to occur-kill-line to occur-mode-map making it available as occur command just pressing k.

An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.

Something as straightforward like this can help you:

(defun occur-kill-line()
    "Quick and dirty discard line from occur resultset."
    (interactive)
    (read-only-mode -1)
    (kill-whole-line)(delete-blank-lines)
    (read-only-mode +1))

invoking this function will kill the current line in occur buffer. Pressing g will revert the buffer.

Adding this:

(define-key occur-mode-map (kbd "k") 'occur-kill-line)

will bind k to occur-kill-line to occur-mode-map making it available as occur command just pressing k.

An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.

Something as straightforward like this can help you:

(defun occur-kill-line()
  "Quick and dirty discard line from occur resultset. (from
https://emacs.stackexchange.com/a/52865/13589)"
  (interactive)
  (let ((buffer-read-only nil))
    (kill-whole-line)
    (delete-blank-lines)))

invoking this function will kill the current line in occur buffer. Pressing g will revert the buffer.

Adding this:

(define-key occur-mode-map (kbd "k") 'occur-kill-line)

will bind k to occur-kill-line to occur-mode-map making it available as occur command just pressing k.

Kill whole line instead of just kill line, to work even if the cursor is not in the first column
Source Link

An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.

Something as straightforward like this can help you:

(defun occur-kill-line()
    "Quick and dirty discard line from occur resultset."
    (interactive)
    (read-only-mode -1)
    (kill-whole-line)(delete-blank-lines)
    (read-only-mode +1))

invoking this function will kill the current line in occur buffer. Pressing g will revert the buffer.

Adding this:

(define-key occur-mode-map (kbd "k") 'occur-kill-line)

will bind k to occur-kill-line to occur-mode-map making it available as occur command just pressing k.

An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.

Something as straightforward like this can help you:

(defun occur-kill-line()
    "Quick and dirty discard line from occur resultset."
    (interactive)
    (read-only-mode -1)
    (kill-line)(delete-blank-lines)
    (read-only-mode +1))

invoking this function will kill the current line in occur buffer. Pressing g will revert the buffer.

Adding this:

(define-key occur-mode-map (kbd "k") 'occur-kill-line)

will bind k to occur-kill-line to occur-mode-map making it available as occur command just pressing k.

An occur buffer is just a buffer in read-only mode, that doesn't mean that it cannot be manipulated.

Something as straightforward like this can help you:

(defun occur-kill-line()
    "Quick and dirty discard line from occur resultset."
    (interactive)
    (read-only-mode -1)
    (kill-whole-line)(delete-blank-lines)
    (read-only-mode +1))

invoking this function will kill the current line in occur buffer. Pressing g will revert the buffer.

Adding this:

(define-key occur-mode-map (kbd "k") 'occur-kill-line)

will bind k to occur-kill-line to occur-mode-map making it available as occur command just pressing k.

added 5 characters in body
Source Link
Muihlinn
  • 2.7k
  • 1
  • 15
  • 22
Loading
added 196 characters in body
Source Link
Muihlinn
  • 2.7k
  • 1
  • 15
  • 22
Loading
Source Link
Muihlinn
  • 2.7k
  • 1
  • 15
  • 22
Loading