emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 51bd02b95c 1/2: Add initial version of 'denote-r


From: ELPA Syncer
Subject: [elpa] externals/denote 51bd02b95c 1/2: Add initial version of 'denote-rename-buffer' extension
Date: Sun, 28 May 2023 03:57:43 -0400 (EDT)

branch: externals/denote
commit 51bd02b95cb045e8ad6fa6991b20eb15d6ccd85c
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add initial version of 'denote-rename-buffer' extension
    
    This is related to the discussion I had on the GitHub mirror issue 151
    with Morgan Davidson about the name of a Denote buffer:
    <https://github.com/protesilaos/denote/issues/151>.
---
 denote-rename-buffer.el | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/denote-rename-buffer.el b/denote-rename-buffer.el
new file mode 100644
index 0000000000..3582f33e9b
--- /dev/null
+++ b/denote-rename-buffer.el
@@ -0,0 +1,57 @@
+;;; denote-rename-buffer.el --- Rename Denote buffers to be shorter and easier 
to read -*- lexical-binding: t -*-
+
+;; Copyright (C) 2023  Free Software Foundation, Inc.
+
+;; Author: Protesilaos Stavrou <info@protesilaos.com>
+;; Maintainer: Denote Development <~protesilaos/denote@lists.sr.ht>
+;; URL: https://git.sr.ht/~protesilaos/denote
+;; Mailing-List: https://lists.sr.ht/~protesilaos/denote
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; Rename Denote buffers to be shorter and easier to read.
+
+;;; Code:
+
+(require 'denote)
+
+(defgroup denote-rename-buffer nil
+  "Rename Denote buffers to be shorter and easier to read."
+  :group 'denote)
+
+;; TODO 2023-05-28: Provide a `denote-rename-buffer-pattern' user option.
+
+(defun denote-rename-buffer (&optional buffer)
+  "Retrieve Denote file of BUFFER and rename BUFFER based on the file title.
+BUFFER is an object that satisfies `bufferp'.  If nil, then use
+the return value of `current-buffer'."
+  (when-let* ((file (buffer-file-name (or buffer (current-buffer))))
+              ((denote-file-has-identifier-p file))
+              (type (denote-filetype-heuristics file))
+              (title (denote--retrieve-title-or-filename file type)))
+    (rename-buffer title :unique)))
+
+(define-minor-mode denote-rename-buffer-mode
+  "Automatically rename Denote buffers to be easier to read."
+  :global t
+  (if denote-rename-buffer-mode
+      (add-hook 'find-file-hook #'denote-rename-buffer)
+    (remove-hook 'find-file-hook #'denote-rename-buffer)))
+
+(provide 'denote-rename-buffer)
+;;; denote-rename-buffer.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]