cleanup: remove 3 unused Plan-file bookmark functions

This commit is contained in:
2026-07-17 21:15:34 -04:00
parent 9126b62d57
commit b5f11df3be
2 changed files with 6 additions and 126 deletions

View File

@@ -3556,52 +3556,8 @@ to .org files under the project root."
(let ((default-directory (projectile-project-root)))
(gortium/read-dir-local 'gortium/project-tag))))
(defun gortium/read-plan-bookmarks ()
"Parse * Bookmarks from the Plan file.
Returns alist ((NAME . URL) ...) where URL is the link target."
(when-let* ((plan-file (gortium/project-plan-file))
(_ (file-exists-p plan-file)))
(with-temp-buffer
(insert-file-contents plan-file)
(goto-char (point-min))
(when (re-search-forward "^\* Bookmarks" nil t)
(forward-line 1)
(let ((bookmarks '()))
(while (not (or (eobp) (looking-at "^\* ")))
(cond
;; ** Name\n[[file:path][Name]]
((looking-at "^\*\* \(.+\)
\[\[file:\(.+\)\]\[\(.+\)\]\]")
(push (cons (match-string 1) (match-string 2)) bookmarks)
(forward-line 2))
;; standalone [[url][name]]
((looking-at "\[\[\(.+\)\]\[\(.+\)\]\]")
(unless (string-prefix-p "mu4e:" (match-string 1))
(push (cons (match-string 2) (match-string 1)) bookmarks))
(forward-line 1))
(t (forward-line 1))))
(setq gortium/project-bookmark-names (mapcar #'car bookmarks))
(nreverse bookmarks))))))
(defun gortium/remove-bookmark-from-plan (name)
"Remove a bookmark entry from * Bookmarks in the Plan file."
(when-let* ((plan-file (gortium/project-plan-file)))
(with-temp-buffer
(insert-file-contents plan-file)
(goto-char (point-min))
(when (re-search-forward (format "^\*\* %s
" (regexp-quote name)) nil t)
(forward-line -1)
(let ((start (point)))
(forward-line 2)
(delete-region start (point)))
(write-region (point-min) (point-max) plan-file nil 'silent)
(message "Bookmark '%s' removed from Plan file" name)
(setq gortium/project-bookmark-names
(delete name gortium/project-bookmark-names))))))
(
(
(defun gortium/bookmark-set ()
"Save a bookmark. Prompts: (g)lobal or (p)roject.
Project bookmarks go to .bookmarks file in project root."
@@ -3661,23 +3617,7 @@ Project bookmarks are deleted from the .bookmarks file in the project root."
(bookmark-save nil proj-file t)
(message "Deleted project bookmark: %s" bm-name))))))))))))
(defun gortium/sync-plan-to-bookmark-file (bookmarks)
"Write BOOKMARKS alist back to the Plan file under * Bookmarks."
(when-let* ((plan-file (gortium/project-plan-file)))
(with-temp-buffer
(insert-file-contents plan-file)
(when (re-search-forward "^\* Bookmarks" nil t)
(forward-line 1)
(let ((start (point)))
(if (re-search-forward "^\* " nil t)
(forward-line -1)
(goto-char (point-max)))
(delete-region start (point)))
(dolist (bm (nreverse (copy-tree bookmarks)))
(insert (format "[[%s][%s]]
" (cdr bm) (car bm))))
(write-region (point-min) (point-max) plan-file nil 'silent)))))
(
(defun gortium/transfer-to-project ()
"Transfer a global bookmark to the current project's .bookmarks."
(interactive)

View File

@@ -2623,52 +2623,8 @@ to .org files under the project root."
(let ((default-directory (projectile-project-root)))
(gortium/read-dir-local 'gortium/project-tag))))
(defun gortium/read-plan-bookmarks ()
"Parse * Bookmarks from the Plan file.
Returns alist ((NAME . URL) ...) where URL is the link target."
(when-let* ((plan-file (gortium/project-plan-file))
(_ (file-exists-p plan-file)))
(with-temp-buffer
(insert-file-contents plan-file)
(goto-char (point-min))
(when (re-search-forward "^\* Bookmarks" nil t)
(forward-line 1)
(let ((bookmarks '()))
(while (not (or (eobp) (looking-at "^\* ")))
(cond
;; ** Name\n[[file:path][Name]]
((looking-at "^\*\* \(.+\)
\[\[file:\(.+\)\]\[\(.+\)\]\]")
(push (cons (match-string 1) (match-string 2)) bookmarks)
(forward-line 2))
;; standalone [[url][name]]
((looking-at "\[\[\(.+\)\]\[\(.+\)\]\]")
(unless (string-prefix-p "mu4e:" (match-string 1))
(push (cons (match-string 2) (match-string 1)) bookmarks))
(forward-line 1))
(t (forward-line 1))))
(setq gortium/project-bookmark-names (mapcar #'car bookmarks))
(nreverse bookmarks))))))
(defun gortium/remove-bookmark-from-plan (name)
"Remove a bookmark entry from * Bookmarks in the Plan file."
(when-let* ((plan-file (gortium/project-plan-file)))
(with-temp-buffer
(insert-file-contents plan-file)
(goto-char (point-min))
(when (re-search-forward (format "^\*\* %s
" (regexp-quote name)) nil t)
(forward-line -1)
(let ((start (point)))
(forward-line 2)
(delete-region start (point)))
(write-region (point-min) (point-max) plan-file nil 'silent)
(message "Bookmark '%s' removed from Plan file" name)
(setq gortium/project-bookmark-names
(delete name gortium/project-bookmark-names))))))
(
(
(defun gortium/bookmark-set ()
"Save a bookmark. Prompts: (g)lobal or (p)roject.
Project bookmarks go to .bookmarks file in project root."
@@ -2728,23 +2684,7 @@ Project bookmarks are deleted from the .bookmarks file in the project root."
(bookmark-save nil proj-file t)
(message "Deleted project bookmark: %s" bm-name))))))))))))
(defun gortium/sync-plan-to-bookmark-file (bookmarks)
"Write BOOKMARKS alist back to the Plan file under * Bookmarks."
(when-let* ((plan-file (gortium/project-plan-file)))
(with-temp-buffer
(insert-file-contents plan-file)
(when (re-search-forward "^\* Bookmarks" nil t)
(forward-line 1)
(let ((start (point)))
(if (re-search-forward "^\* " nil t)
(forward-line -1)
(goto-char (point-max)))
(delete-region start (point)))
(dolist (bm (nreverse (copy-tree bookmarks)))
(insert (format "[[%s][%s]]
" (cdr bm) (car bm))))
(write-region (point-min) (point-max) plan-file nil 'silent)))))
(
(defun gortium/transfer-to-project ()
"Transfer a global bookmark to the current project's .bookmarks."
(interactive)