emacs-wiki-discuss
[Top][All Lists]
Advanced

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

[emacs-wiki-discuss] w3m bookmark system using muse


From: Yvonne Thomson
Subject: [emacs-wiki-discuss] w3m bookmark system using muse
Date: Sun, 23 Oct 2005 12:33:39 +1000
User-agent: Wanderlust/2.14.0 (Africa) Emacs/21.3 Mule/5.0 (SAKAKI)

Hi all.

During another discussion a few days ago, a few of you said you'd be
interested to see my w3m muse bookmarking code. Let me just say at the
outset, this works for me. Let me also say that I'm blind, and I have no
idea esthetically how this should work. I mean, should it appear in
another window? Should the buffer stay permanently open or shut? These
are the sorts of things I don't really think about. If anyone uses this
code and cleans it up visually, let me know.

The instructions in the comments should be enough to get you going, but
let me know if they're not or if something doesn't work.

;;; muse-w3m-bookmarks.el --- Bookmarks for w3m using Muse

;; Copyright (C) 2005 Yvonne Thomson


;; This file is not part of GNU Emacs.

;; This 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 2, or (at your option) any later
;; version.
;;
;; This 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 GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
;; MA 02111-1307, USA.

;;; Commentary:
;;
;;This is, basically, a drop-in replacement for w3m's bookmarking
;;system.  Simply add keybindings to the w3m keymap for

;;w3m-muse-bookmark-view, w3m-muse-bookmark-add-current-url and
;;w3m-muse-bookmark-add-this-url.

;;You will also need to add a bookmarks project to your
;;muse-projects-alist, which will default to Bookmarks if you don't
;;override the w3m-muse-bookmark-project variable..

;;;code
(require 'muse-mode)
(defvar w3m-muse-bookmark-project "Bookmarks"
  "*Name of the bookmarks muse project")

(defun w3m-muse-bookmark-add (url &optional title section)
  "Add URL to bookmark.
Optional argument TITLE is title of link."
  (setq title (read-string "Title: " title 'w3m-bookmark-title-history))
  (when (or (not title)
            (string-match title "^ *$"))
    (error "%s" "You must specify title"))
  (setq section       (car(muse-read-project-file w3m-muse-bookmark-project 
"Section: ")))
  (save-window-excursion
    (muse-project-find-file section w3m-muse-bookmark-project)
    (turn-off-auto-fill)
    (goto-char(point-max))
    (insert (muse-make-link url title))
    (newline)
    (save-buffer 0)
    (kill-buffer nil)
    ))



(defun w3m-muse-bookmark-add-current-url (&optional arg)
  "Add link of current page to bookmark.
With prefix, ask new url to add instead of current page."
  (interactive "P")
  (w3m-muse-bookmark-add (if arg (w3m-input-url) w3m-current-url)
                         w3m-current-title)
  (message "Added"))

(defun w3m-muse-bookmark-add-this-url ()
  "Add link under cursor to bookmark."
  (interactive)
  (if (null (w3m-anchor))
      (message "No anchor")             ; nothing to do
    (let ((url (w3m-anchor))
          (title (buffer-substring-no-properties
                  (previous-single-property-change (1+ (point)) 
'w3m-href-anchor)
                  (next-single-property-change (point) 'w3m-href-anchor))))
      (w3m-muse-bookmark-add url title))
    (message "Added")))

(defun w3m-muse-bookmark-view ()
  "View a section of the bookmark list"
  (interactive)
  (let((section
        (car(muse-read-project-file w3m-muse-bookmark-project "Section: "))))
    (muse-project-find-file section w3m-muse-bookmark-project)))




reply via email to

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