all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Ibuffer: Indicate when one buffer is locked
@ 2016-06-15  5:55 C. Calancha
  0 siblings, 0 replies; only message in thread
From: C. Calancha @ 2016-06-15  5:55 UTC (permalink / raw)
  To: emacs-devel


Hi,

The initial columns in Ibuffer are respectively:

* mark (indicate the buffer is marked)
* modified (indicate the buffer is modified)
* read-only (indicate the buffer is read-only)

After that is the column with the buffer names.

I would like Ibuffer indicate when a buffer is locked as well.

I suggest following patch:

* First part adds a new column 'locked' right after 'read-only' column;
   this column displays ?L when the buffer is locked.

* Second part of the patch introduce a face to display
   the locked buffers.

Your opinions are very welcome.

Tino

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 098fa70e5d4a8346edbbf6878e5fdd970230e3cd Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac@gmail.com>
Date: Wed, 15 Jun 2016 13:40:48 +0900
Subject: [PATCH 1/2] * lisp/ibuffer.el: Add mark for locked buffers

---
  lisp/ibuffer.el | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index 609524c..f9a11a8 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -71,7 +71,8 @@ ibuffer
    :version "22.1"
    :group 'convenience)

-(defcustom ibuffer-formats '((mark modified read-only " " (name 18 18 
:left :elide)
+(defcustom ibuffer-formats '((mark modified read-only locked
+                                   " " (name 18 18 :left :elide)
  				   " " (size 9 -1 :right)
  				   " " (mode 16 16 :left :elide) " " 
filename-and-process)
  			     (mark " " (name 16 -1) " " filename))
@@ -275,6 +276,12 @@ ibuffer-read-only-char
    :type 'character
    :group 'ibuffer)

+(defcustom ibuffer-locked-char ?L
+  "The character to display for locked buffers."
+  :version "25.2"
+  :type 'character
+  :group 'ibuffer)
+
  (defcustom ibuffer-marked-char ?>
    "The character to display for marked buffers."
    :type 'character
@@ -1721,6 +1728,12 @@ read-only
        (string ibuffer-read-only-char)
      " "))

+(define-ibuffer-column locked
+  (:name "L" :inline t)
+  (if (and (boundp 'emacs-lock-mode) emacs-lock-mode)
+      (string ibuffer-locked-char)
+    " "))
+
  (define-ibuffer-column modified (:name "M" :inline t)
    (if (buffer-modified-p)
        (string ibuffer-modified-char)
-- 
2.8.1

From 07fa2ffa954f349b0c9a6f4029c47a048b0e64c1 Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac@gmail.com>
Date: Wed, 15 Jun 2016 14:05:56 +0900
Subject: [PATCH 2/2] * lisp/ibuffer.el: Add font for locked buffers

---
  lisp/ibuffer.el | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index f9a11a8..7bf2e31 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -159,7 +159,8 @@ ibuffer-fontification-alist
  	     (null buffer-file-name))
  	italic)
      (30 (memq major-mode ibuffer-help-buffer-modes) 
font-lock-comment-face)
-    (35 (derived-mode-p 'dired-mode) font-lock-function-name-face))
+    (35 (derived-mode-p 'dired-mode) font-lock-function-name-face)
+    (40 (and (boundp 'emacs-lock-mode) emacs-lock-mode) 
ibuffer-locked-buffer))
    "An alist describing how to fontify buffers.
  Each element should be of the form (PRIORITY FORM FACE), where
  PRIORITY is an integer, FORM is an arbitrary form to evaluate in the
@@ -1720,6 +1721,15 @@ ibuffer-check-formats

  (defvar ibuffer-inline-columns nil)

+(defface ibuffer-locked-buffer
+  '((((background dark)) (:foreground "RosyBrown"))
+    (t (:foreground "brown4")))
+  "*Face used for locked buffers in Ibuffer."
+  :version "25.2"
+  :group 'ibuffer
+  :group 'font-lock-highlighting-faces)
+(defvar ibuffer-locked-buffer 'ibuffer-locked-buffer)
+
  (define-ibuffer-column mark (:name " " :inline t)
    (string mark))

@@ -1729,7 +1739,7 @@ read-only
      " "))

  (define-ibuffer-column locked
-  (:name "L" :inline t)
+  (:name "L" :inline t :props ('font-lock-face 'ibuffer-locked-buffer))
    (if (and (boundp 'emacs-lock-mode) emacs-lock-mode)
        (string ibuffer-locked-char)
      " "))
-- 
2.8.1





^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-15  5:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-15  5:55 Ibuffer: Indicate when one buffer is locked C. Calancha

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.