all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "C. Calancha" <tino.calancha@gmail.com>
To: emacs-devel@gnu.org
Subject: Ibuffer: Indicate when one buffer is locked
Date: Wed, 15 Jun 2016 14:55:42 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1606151454150.2033@calancha-pc> (raw)


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





                 reply	other threads:[~2016-06-15  5:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1606151454150.2033@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.