Re: weblogger.el and tags

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: weblogger.el and tags

Mark A. Hershberger
[Ccing the emacsweblogs mailing list]

David Abrahams <[hidden email]> writes:

> I select the body of the buffer, then `M-x
> my-clone-region-set-mode<RET>markdown-mode' and away I go.  The only
> problem is that unless I make changes *directly* in the weblogger-entry
> buffer (not the clone), `C-c C-c' in the weblogger-entry buffer tells me
> "nothing to post."

I have been thinking about ways to make weblogger.el work with other
modes better.  Some people prefer to type theirs up in SGML, others
nxhtml, others org, and still others (e.g. you) in markdown.

I think the way to solve this is to tie the weblogger buffer to the
“content” buffer instead of the other way around.  That way, for
example, you would start writing up your blog entry in a markdown mode
buffer and then invoke, say, weblogger-convert-and-post-buffer.

weblogger-convert-and-post-buffer would look for a buffer-local variable
(say, weblogger-conversion-function) that points to a conversion
function.  It would call this function to get HTML code suitable for
posting.

This HTML would be used for the body section of the post and you could
fill out the other fields as needed.

If you change the primary buffer, weblogger.el would be able to see that
and update the body of the post.  You'd still be able to use
weblogger.el to edit the raw html if you wish, of course.

The could be other hooks for weblogger-convert-and-post-buffer to use.
Org, for instance, allows you to set the title for a buffer and this
could be carried over to the title of the weblogger post.  Similar
things could be done for date stamps, tags, etc.

What do you think?

Mark.

--
http://hexmode.com/

Every day, mindful practice.  When the mind is disciplined, then the
Way can work for us.  Otherwise, all we do is talk of the Way; everything
is just words; and the world will know us as its one great fool.


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger.el and tags

Dave Abrahams
Hi Mark,

Sorry about the slow response time.  Busy blogging ;-)

On Aug 30, 2009, at 9:27 PM, Mark A. Hershberger wrote:

> [Ccing the emacsweblogs mailing list]
>
> David Abrahams <[hidden email]> writes:
>
>> I select the body of the buffer, then `M-x
>> my-clone-region-set-mode<RET>markdown-mode' and away I go.  The only
>> problem is that unless I make changes *directly* in the weblogger-
>> entry
>> buffer (not the clone), `C-c C-c' in the weblogger-entry buffer  
>> tells me
>> "nothing to post."
>
> I have been thinking about ways to make weblogger.el work with other
> modes better.  Some people prefer to type theirs up in SGML, others
> nxhtml, others org, and still others (e.g. you) in markdown.
>
> I think the way to solve this is to tie the weblogger buffer to the
> “content” buffer instead of the other way around.

Well, perhaps.  I don't know enough about the internals of  
weblogger.el to really understand what that means.

> That way, for
> example, you would start writing up your blog entry in a markdown mode
> buffer and then invoke, say, weblogger-convert-and-post-buffer.

That could work, but what about editing an existing draft?

> weblogger-convert-and-post-buffer would look for a buffer-local  
> variable
> (say, weblogger-conversion-function) that points to a conversion
> function.  It would call this function to get HTML code suitable for
> posting


Oh, gee, I don't think I want that!  My posts really are written in  
Markdown, not raw HTML.  I'm using Wordpress plugins that cause the  
Markdown to be displayed as HTML, dynamically.

> This HTML would be used for the body section of the post and you could
> fill out the other fields as needed.
>
> If you change the primary buffer, weblogger.el would be able to see  
> that
> and update the body of the post.  You'd still be able to use
> weblogger.el to edit the raw html if you wish, of course.
>
> The could be other hooks for weblogger-convert-and-post-buffer to use.
> Org, for instance, allows you to set the title for a buffer and this
> could be carried over to the title of the weblogger post.  Similar
> things could be done for date stamps, tags, etc.
>
> What do you think?

Really, I just want my clone-region-set-mode thingy to work (i.e.  
cause weblogger to know the buffer has been changed).  I'll probably  
want to do the clone thing at multiple levels anyway, since I put C++  
code in my blog posts and I'll sometimes want to edit that in c++-mode.

BTW, how do I create a new post with weblogger?  It's totally awesome  
aside from these two issues I can't seem to get around!

--
David Abrahams
BoostPro Computing
http://boostpro.com






_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger.el and tags

Mark A. Hershberger
David Abrahams <[hidden email]> writes:

> BTW, how do I create a new post with weblogger?  It's totally awesome
> aside from these two issues I can't seem to get around!

From the header:

;; I use the following commands in my .emacs file:
;;
;; (load-file "weblogger.el")
;; (global-set-key "\C-cbs" 'weblogger-start-entry)

Or you could just

    M-x weblogger-start-entry RET

That should do what you need.

Mark.

--
http://hexmode.com/

Every day, mindful practice.  When the mind is disciplined, then the
Way can work for us.  Otherwise, all we do is talk of the Way; everything
is just words; and the world will know us as its one great fool.


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

weblogger & major mode

Mark A. Hershberger
In reply to this post by Dave Abrahams

Based on David Abrahams' and Andrea Crotti's feedback, I've put together
a quick hack to toggle the weblogger-entry buffer between the major mode
of your choice.

I'd like to see what you guys think before committing this, so I've made
my changes available at <http://winkyfrown.com/weblogger.el>.

Some notes on the use of this:

   * There are three new customizations:

     + weblogger-edit-mode - The major mode to switch to for editing the
       content.
     + weblogger-edit-mode-toggle-hook - hook to run when switching to
       the above mode.
     + weblogger-weblogger-mode-toggle-hook - hook to run when switching
       back to weblogger-entry-mode

   * In the weblogger-entry-mode, I've added a keybinding (C-c C-e) to
     switch to editting the body in the major-mode you put in
     weblogger-edit-mode (defaults to nxml-mode, but I'm open to
     suggestions for a better mode).

     When you switch major modes this way, the header is removed, the
     hooks are run and you can edit the body using whatever you're used
     to.

   * When you want to switch back to edit the meta-data and/or submit
     the entry, you would do “M-x weblogger-toggle-edit-body RET” and
     the headers will be inserted back into the buffer and the buffer
     will be switched back to weblogger-entry-mode.

Let me know what you think!

Mark.

--
http://hexmode.com/

Every day, mindful practice.  When the mind is disciplined, then the
Way can work for us.  Otherwise, all we do is talk of the Way; everything
is just words; and the world will know us as its one great fool.

=== modified file 'lisp/weblogger.el'
--- lisp/weblogger.el 2009-09-13 06:15:53 +0000
+++ lisp/weblogger.el 2009-09-18 02:26:58 +0000
@@ -242,6 +242,21 @@
   :group 'weblogger
   :type 'hook)
 
+(defcustom weblogger-edit-mode 'nxml-mode
+  "Major mode to use for editing weblog entries"
+  :group 'weblogger
+  :type 'function)
+
+(defcustom weblogger-edit-mode-toggle-hook nil
+  "Hook to call when switching to edit mode"
+  :group 'weblogger
+  :type 'hook)
+
+(defcustom weblogger-weblogger-mode-toggle-hook nil
+  "Hook to call when switching back to weblogger mode"
+  :group 'weblogger
+  :type 'hook)
+
 (defvar weblogger-entry-list nil
   "List of weblog entries that we know about. Chronological
 order, with newest first.")
@@ -305,6 +320,9 @@
 
 (defvar menu-bar-weblogger-menu nil)
 
+(defvar weblogger-header nil
+  "Holds the weblog header")
+
 (defconst weblogger-blogger-app-key
   "07C72E6970E0FBA5DE21BA9F4800C44534C19870"
   "OBSOLETE. The appkey to send to weblog server.  Generally this
@@ -400,6 +418,7 @@
           (define-key map "\C-c\C-o" 'weblogger-change-server)
           (define-key map "\C-c\C-w" 'weblogger-change-weblog)
           (define-key map "\C-c\C-u" 'weblogger-change-user)
+          (define-key map "\C-c\C-e" 'weblogger-toggle-edit-body)
           map)))
 
 (unless weblogger-template-mode-map
@@ -514,17 +533,14 @@
  (weblogger-select-texttype))))
     (goto-char point-save)))
 
-(defun weblogger-entry-mode ()
+(define-derived-mode weblogger-entry-mode message-mode "Weblog"
   "Major mode for editing text for Weblogger.  Based on message-mode."
-  (interactive)
-  (message-mode)
-  (message-disassociate-draft)
-  (use-local-map weblogger-entry-mode-map)
-  (setq mode-name "weblogger-entry")
-  (setq major-mode 'weblogger-entry-mode)
+  ;; (interactive)
+  ;; (message-mode)
+  ;; (message-disassociate-draft)
+  ;; (use-local-map weblogger-entry-mode-map)
   (unless weblogger-entry-ring
-    (setq weblogger-entry-ring (make-ring weblogger-max-entries-in-ring)))
-  (run-hooks 'weblogger-entry-mode-hook))
+    (setq weblogger-entry-ring (make-ring weblogger-max-entries-in-ring))))
 
 (defun weblogger-template-mode ()
   "Major mode for editing templates for Weblogger. Based on text-mode."
@@ -1329,6 +1345,24 @@
                      (buffer-substring-no-properties
                       (point) (point-max)))))))))
 
+(defun weblogger-toggle-edit-body ()
+  "Toggle between editting the body and editting the headers"
+  (interactive)
+  (if (string= mode-name "Weblog")
+      (progn
+        (message-goto-body)
+        (setq weblogger-header (buffer-substring (point-min) (point)))
+        (delete-region (point-min) (point))
+        (run-hooks 'weblogger-edit-mode-toggle-hook)
+        (funcall weblogger-edit-mode)
+        (make-local-variable 'weblogger-header))
+    (if (not (assoc 'weblogger-header (buffer-local-variables)))
+        (error "You didn't come here from a weblogger buffer, so we can switch back")
+      (goto-char (point-min))
+      (insert weblogger-header)
+      (run-hooks 'weblogger-weblogger-mode-toggle-hook)
+      (weblogger-entry-mode))))
+
 ;; TODO -- Support for toolbar
 ;; (eval-when-compile (defvar tool-bar-map))
 ;; (if (featurep 'xemacs)



_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger.el and tags

Dave Abrahams
In reply to this post by Mark A. Hershberger

on Thu Sep 17 2009, mah-AT-everybody.org (Mark A. Hershberger) wrote:

> David Abrahams <[hidden email]> writes:
>
>> BTW, how do I create a new post with weblogger?  It's totally awesome
>> aside from these two issues I can't seem to get around!
>
>>From the header:
>
> ;; I use the following commands in my .emacs file:
> ;;
> ;; (load-file "weblogger.el")
> ;; (global-set-key "\C-cbs" 'weblogger-start-entry)
>
> Or you could just
>
>     M-x weblogger-start-entry RET
>
> That should do what you need.

Oh, very cool; thanks!

Now, is there also a way to submit an update to an entry without the
*weblogger-entry* buffer hiding itself?

--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

andrea crotti-2
In reply to this post by Mark A. Hershberger
Mark A. Hershberger <mah <at> everybody.org> writes:
> Let me know what you think!
>
> Mark.
>


I think it's a good idea!
Anyway doing the following:
- fetch entries
- weblogger-toogle-edit-body
- html-mode (was nxml mode)

gave me
Using vacuous schema
Text not allowed [37 times]
if: Wrong type argument: stringp, (sgml-xml-mode "XHTML" "HTML")

Maybe doesn't want me to change the major mode?

A (maybe) ugly hack that could be useful would be
allowing elisp code in weblogger-entry-mode, in this way
I can dinamically insert my other buffers (in other modes) and then post them.

Something like "execute-elisp-and-post-entry".



_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: Re: weblogger & major mode

Mark A. Hershberger
andrea Crotti <[hidden email]> writes:

> I think it's a good idea!
> Anyway doing the following:
> - fetch entries
> - weblogger-toogle-edit-body
> - html-mode (was nxml mode)

Right.  You want to customize weblogger-edit-mode to html-mode.
Alternatively, you could set it to a lambda function that will prompt you
for a mode.  (Come to think of it, a prompt is probably a better way to
handle this.)

> A (maybe) ugly hack that could be useful would be
> allowing elisp code in weblogger-entry-mode, in this way
> I can dinamically insert my other buffers (in other modes) and then post them.
>
> Something like "execute-elisp-and-post-entry".

You can do this now by customizing weblogger-pre-struct-hook with a list
of functions that you want executed before function.  These could
include functions to do pretty much any conversion on the buffer you
like.

Alternatively, you could customize weblogger-weblogger-mode-toggle-hook
so that the buffer you've been working on is translated somehow before
it is switched back to weblogger-entry-mode.  This could include, for
example, translating an org-mode buffer into an html snippet.

I'll try to post an example of how this would work today.

Mark.

--
http://hexmode.com/

Every day, mindful practice.  When the mind is disciplined, then the
Way can work for us.  Otherwise, all we do is talk of the Way; everything
is just words; and the world will know us as its one great fool.


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

Dave Abrahams
In reply to this post by Mark A. Hershberger

on Thu Sep 17 2009, mah-AT-everybody.org (Mark A. Hershberger) wrote:

> Based on David Abrahams' and Andrea Crotti's feedback, I've put together
> a quick hack to toggle the weblogger-entry buffer between the major mode
> of your choice.

Thanks for working on this, Mark!

> I'd like to see what you guys think before committing this, so I've made
> my changes available at <http://winkyfrown.com/weblogger.el>.

Well, my first thought is "why didn't he use something based on
clone-indirect-buffer and narrow-to-region instead of actually inserting
and removing headers?"  Take a look at my-clone-region-set-mode in the
enclosed.  It somehow seems like a more principled approach.

> Some notes on the use of this:
>
>    * There are three new customizations:
>
>      + weblogger-edit-mode - The major mode to switch to for editing the
>        content.
>      + weblogger-edit-mode-toggle-hook - hook to run when switching to
>        the above mode.
>      + weblogger-weblogger-mode-toggle-hook - hook to run when switching
>        back to weblogger-entry-mode
>
>    * In the weblogger-entry-mode, I've added a keybinding (C-c C-e) to
>      switch to editting the body in the major-mode you put in
>      weblogger-edit-mode (defaults to nxml-mode, but I'm open to
>      suggestions for a better mode).
Nice feature.

>      When you switch major modes this way, the header is removed, the
>      hooks are run and you can edit the body using whatever you're used
>      to.
>
>    * When you want to switch back to edit the meta-data and/or submit
>      the entry, you would do “M-x weblogger-toggle-edit-body RET” and
>      the headers will be inserted back into the buffer and the buffer
>      will be switched back to weblogger-entry-mode.
>
> Let me know what you think!
The only thing I really wanted corrected was that if I edited a clone of
the *weblogger-entry* buffer, its contents would be updated, but somehow
weblogger-entry-mode wouldn't know that it had been changed, so they
could be too easily lost, for example, by `C-c C-n'.  I think I'd still
really like that to be fixed, no matter what else is done.

Thanks!


;;
;; General utilities
;;

(defun my-kill-buffer ()
  "Just kill the current buffer without asking, unless of course it's a
modified file"
  (interactive)
  (kill-buffer (current-buffer)))

(defun my-switch-to-previous-buffer ()
  "Switch to the most recently visited buffer without asking"
  (interactive)
  (switch-to-buffer nil))

(defun my-info-other-frame ()
  (interactive)
  (select-frame (make-frame))
  (info))

(defun my-mark-or-point ()
  "Return the mark if it is active, otherwise the point."
  (if
      (if (fboundp 'region-active-p) (region-active-p) mark-active)
      (mark)
    (point)))

(defun my-selection ()
  "Return a pair [start . finish) delimiting the current selection"
      (let ((start (make-marker))
            (finish (make-marker)))
        (set-marker start (min (my-mark-or-point) (point)))

        (set-marker finish (max (my-mark-or-point) (point)))
        (cons start finish)))

(defun my-replace-in-region (start finish key replacement)
  "In the range [START, FINISH), replace text matching KEY with REPLACEMENT"
  (goto-char start)
  (while (search-forward key finish t)
    (replace-match replacement)))

(defun my-activate-mark ()
  "Make the mark active if it is currently inactive"
  (set-mark (mark t)))


(defun my-matching-paren (arg)
  (interactive "P")
  (if arg
      () ;;(insert "%")  ; insert the character we're bound to
    (cond ((looking-at "[[({]")
           (forward-sexp 1)
           (forward-char -1))
          ((looking-at "[]})]")
           (forward-char 1)
           (forward-sexp -1))
          (t
           ;; (insert "%")  ; insert the character we're bound to
      ))))

; Something for converting DOS files to unix format
(defun my-use-code-undecided-unix ()
  (interactive)
  (set-buffer-file-coding-system 'undecided-unix)
  (save-buffer))

(defun my-other-window-backward (&optional n)
  "Select the previous window. Copied from \"Writing Gnu Emacs Extensions\"."
  (interactive "P")
  (other-window (- (or n 1)))
  )

; return the first non-nil result of applying f to each element of seq
(defun my-first-non-nil (seq f)
  (and seq
       (or
        (apply f (list (car seq)))
        (my-first-non-nil (cdr seq) f)))
  )

(defun my-mode-read ()
  (let ((symb 'c++-mode)
        (predicate 'commandp)
        (enable-recursive-minibuffers t)
        val)
    (setq val (completing-read
               (concat "Mode "
                       (if symb
                           (format " (default %s)" symb))
                       ": ")
               obarray predicate t nil))
    (list (if (equal val "")
              symb
            (intern val)))))

(defun my-clone-region-set-mode (&optional mode)
  (interactive (my-mode-read))
  (let ((pt (point))(mk (my-mark-or-point)))
    (with-current-buffer (clone-indirect-buffer-other-window "*clone*" t)
    (narrow-to-region pt mk)
    (if mode
        (funcall mode)
      (lisp-mode)))))

(provide 'dwa-util)

--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

Mark A. Hershberger
David Abrahams <[hidden email]> writes:

> Well, my first thought is "why didn't he use something based on
> clone-indirect-buffer and narrow-to-region instead of actually inserting
> and removing headers?"  Take a look at my-clone-region-set-mode in the
> enclosed.  It somehow seems like a more principled approach.

In a buffer that has been narrowed, the headers still exist.  While this
is fine for many, perhaps most modes, modes like nxml-mode won't work
with non-XML content at the top of the buffer. (I don't claim to be an
elisp expert, though, so let me know if you see a way around this.)

An alternative is to use something like mumamo.el (see nxhtml) which
allows you to use multiple major modes in a single buffer.  I may try
that in the future, but this quick hack was sufficient for now.

> The only thing I really wanted corrected was that if I edited a clone of
> the *weblogger-entry* buffer, its contents would be updated, but somehow
> weblogger-entry-mode wouldn't know that it had been changed, so they
> could be too easily lost, for example, by `C-c C-n'.  I think I'd still
> really like that to be fixed, no matter what else is done.

Sure.  But I didn't understand your problem.

I've spent some time attempting to reproduce it now, so I have a pretty
good idea of what is happening.

After evaluating your file, I opened up a weblogger-entry-mode buffer
with a currently published entry.  Then I did

    M-; (my-clone-region-set-mode 'org-mode) RET

and edited the cloned buffer.  At this point, I saw that both the cloned
buffer and the original buffer had been marked modified.  Finally, I
switched back to the original buffer and hit “C-c C-n” to go to the next
buffer.

Here's what happens:

    On my MT blog, the published post stays the same.  From the admin
    interface, I can see that the post has been edited, but the new
    version not yet published.

    On my WP.com blog, the post is no longer published, it has gone back
    to the “draft” state.

    On my LJ-based weblog, the post is updated and published.

Since I've been doing most of my testing till now with the LJ weblog, I
didn't catch this before.  It looks like this is related to the other
problem you mentioned:

    When I edit a published article, it seems to become unpublished if I
    just do `C-c C-c' or `C-c C-s'.

Could you verify that and file a bug report here:

    https://savannah.nongnu.org/bugs/?group=emacsweblogs

Thanks,

Mark.

--
http://hexmode.com/

Every day, mindful practice.  When the mind is disciplined, then the
Way can work for us.  Otherwise, all we do is talk of the Way; everything
is just words; and the world will know us as its one great fool.


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

Mark A. Hershberger
In reply to this post by Dave Abrahams
David Abrahams <[hidden email]> writes:

> Well, my first thought is "why didn't he use something based on
> clone-indirect-buffer and narrow-to-region instead of actually inserting
> and removing headers?"  Take a look at my-clone-region-set-mode in the
> enclosed.  It somehow seems like a more principled approach.

In a buffer that has been narrowed, the headers still exist.  While this
is fine for many, perhaps most modes, modes like nxml-mode won't work
with non-XML content at the top of the buffer. (I don't claim to be an
elisp expert, though, so let me know if you see a way around this.)

An alternative is to use something like mumamo.el (see nxhtml) which
allows you to use multiple major modes in a single buffer.  I may try
that in the future, but this quick hack was sufficient for now.

> The only thing I really wanted corrected was that if I edited a clone of
> the *weblogger-entry* buffer, its contents would be updated, but somehow
> weblogger-entry-mode wouldn't know that it had been changed, so they
> could be too easily lost, for example, by `C-c C-n'.  I think I'd still
> really like that to be fixed, no matter what else is done.

Sure.  But I didn't understand your problem.

I've spent some time attempting to reproduce it now, so I have a pretty
good idea of what is happening.

After evaluating your file, I opened up a weblogger-entry-mode buffer
with a currently published entry.  Then I did

    M-; (my-clone-region-set-mode 'org-mode) RET

and edited the cloned buffer.  At this point, I saw that both the cloned
buffer and the original buffer had been marked modified.  Finally, I
switched back to the original buffer and hit “C-c C-n” to go to the next
buffer.

Here's what happens:

    On my MT blog, the published post stays the same.  From the admin
    interface, I can see that the post has been edited, but the new
    version not yet published.

    On my WP.com blog, the post is no longer published, it has gone back
    to the “draft” state.

    On my LJ-based weblog, the post is updated and published.

Since I've been doing most of my testing till now with the LJ weblog, I
didn't catch this before.  It looks like this is related to the other
problem you mentioned:

    When I edit a published article, it seems to become unpublished if I
    just do `C-c C-c' or `C-c C-s'.

Could you verify that and file a bug report here:

    https://savannah.nongnu.org/bugs/?group=emacsweblogs

Thanks,

Mark.

--
http://hexmode.com/

Every day, mindful practice.  When the mind is disciplined, then the
Way can work for us.  Otherwise, all we do is talk of the Way; everything
is just words; and the world will know us as its one great fool.


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

Dave Abrahams
In reply to this post by Mark A. Hershberger

On Sep 18, 2009, at 4:47 PM, Mark A. Hershberger wrote:

> David Abrahams <[hidden email]> writes:
>
>> Well, my first thought is "why didn't he use something based on
>> clone-indirect-buffer and narrow-to-region instead of actually  
>> inserting
>> and removing headers?"  Take a look at my-clone-region-set-mode in  
>> the
>> enclosed.  It somehow seems like a more principled approach.
>
> In a buffer that has been narrowed, the headers still exist.  While  
> this
> is fine for many, perhaps most modes, modes like nxml-mode won't work
> with non-XML content at the top of the buffer.

Oh, I didn't realize that.  I suppose it makes sense, though, as a  
design decision.  Either you accept the hidden stuff may bork the  
mode's parser (status quo) or you accept that eliminating the hidden  
stuff may bork the mode's parser.  I think the status quo is probably  
less prone to surprising behavior.

> (I don't claim to be an
> elisp expert, though, so let me know if you see a way around this.)
>
> An alternative is to use something like mumamo.el (see nxhtml) which
> allows you to use multiple major modes in a single buffer.  I may try
> that in the future, but this quick hack was sufficient for now.

Yeah, I talked to the mumamo guy about this, but he didn't support  
markdown at that time.

>
>> The only thing I really wanted corrected was that if I edited a  
>> clone of
>> the *weblogger-entry* buffer, its contents would be updated, but  
>> somehow
>> weblogger-entry-mode wouldn't know that it had been changed, so they
>> could be too easily lost, for example, by `C-c C-n'.  I think I'd  
>> still
>> really like that to be fixed, no matter what else is done.
>
> Sure.  But I didn't understand your problem.
>
> I've spent some time attempting to reproduce it now, so I have a  
> pretty
> good idea of what is happening.
>
> After evaluating your file, I opened up a weblogger-entry-mode buffer
> with a currently published entry.  Then I did
>
>    M-; (my-clone-region-set-mode 'org-mode) RET
>
> and edited the cloned buffer.  At this point, I saw that both the  
> cloned
> buffer and the original buffer had been marked modified.  Finally, I
> switched back to the original buffer and hit “C-c C-n” to go to the  
> next
> buffer.
>
> Here's what happens:
>
>    On my MT blog, the published post stays the same.  From the admin
>    interface, I can see that the post has been edited, but the new
>    version not yet published.
>
>    On my WP.com blog, the post is no longer published, it has gone  
> back
>    to the “draft” state.
>
>    On my LJ-based weblog, the post is updated and published.
>
> Since I've been doing most of my testing till now with the LJ  
> weblog, I
> didn't catch this before.  It looks like this is related to the other
> problem you mentioned:
>
>    When I edit a published article, it seems to become unpublished  
> if I
>    just do `C-c C-c' or `C-c C-s'.
>
> Could you verify that and file a bug report here:
>
>    https://savannah.nongnu.org/bugs/?group=emacsweblogs

I don't know how I'd verify your analysis, but I'll file the bug report.

--
David Abrahams
BoostPro Computing
http://boostpro.com






_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

Dave Abrahams
In reply to this post by Mark A. Hershberger

on Thu Sep 17 2009, mah-AT-everybody.org (Mark A. Hershberger) wrote:

>    * There are three new customizations:
>
>      + weblogger-edit-mode - The major mode to switch to for editing the
>        content.
>      + weblogger-edit-mode-toggle-hook - hook to run when switching to
>        the above mode.
>      + weblogger-weblogger-mode-toggle-hook - hook to run when switching
>        back to weblogger-entry-mode
>
>    * In the weblogger-entry-mode, I've added a keybinding (C-c C-e) to
>      switch to editting the body in the major-mode you put in
>      weblogger-edit-mode (defaults to nxml-mode, but I'm open to
>      suggestions for a better mode).
>
>      When you switch major modes this way, the header is removed, the
>      hooks are run and you can edit the body using whatever you're used
>      to.
>
>    * When you want to switch back to edit the meta-data and/or submit
>      the entry, you would do “M-x weblogger-toggle-edit-body RET” and
>      the headers will be inserted back into the buffer and the buffer
>      will be switched back to weblogger-entry-mode.
>
> Let me know what you think!

After our recent discussion, I agree with these decisions.

--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger.el and tags

Dave Abrahams
In reply to this post by Mark A. Hershberger

On Sep 17, 2009, at 8:26 PM, Mark A. Hershberger wrote:

> David Abrahams <[hidden email]> writes:
>
>> BTW, how do I create a new post with weblogger?  It's totally awesome
>> aside from these two issues I can't seem to get around!
>
>> From the header:
>
> ;; I use the following commands in my .emacs file:
> ;;
> ;; (load-file "weblogger.el")
> ;; (global-set-key "\C-cbs" 'weblogger-start-entry)
>
> Or you could just
>
>    M-x weblogger-start-entry RET
>
> That should do what you need.

It does, but the menu item for weblogger-save-entry is grayed out, and  
`C-c C-n', for example, drops the work I've done unless I manually `M-
x weblogger-save-entry'

--
David Abrahams
BoostPro Computing
http://boostpro.com






_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

Dave Abrahams
In reply to this post by Mark A. Hershberger

Mark, is this in the mainline yet?

At Thu, 17 Sep 2009 23:29:03 -0400,
Mark A. Hershberger wrote:
>
> Based on David Abrahams' and Andrea Crotti's feedback, I've put together
> a quick hack to toggle the weblogger-entry buffer between the major mode
> of your choice.
>
> I'd like to see what you guys think before committing this, so I've made
> my changes available at <http://winkyfrown.com/weblogger.el>.
>
...


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

Dave Abrahams
In reply to this post by Mark A. Hershberger
At Thu, 17 Sep 2009 23:29:03 -0400,
Mark A. Hershberger wrote:
>
>    * When you want to switch back to edit the meta-data and/or submit
>      the entry, you would do “M-x weblogger-toggle-edit-body RET” and
>      the headers will be inserted back into the buffer and the buffer
>      will be switched back to weblogger-entry-mode.
>
> Let me know what you think!

Finally had a chance to check this out, and I have three comments:


0. Looks pretty nice!

1. entering and exiting the edit mode without making changes marks the
   buffer as modified and these changes seem to get put into the undo
   history.  I don't think we want either of those behaviors.

2. I'd like some universal way to get back to weblogger-mode without
   “M-x weblogger-toggle-edit-body RET”.  In fact, I'd also like to be
   able to post new articles and update existing posts without
   returning to weblogger.  I'm sure I can code these things up
   myself, but if weblogger-mode is aiming to be make blogging
   painless for Emacs users, it should make these kinds of services
   easy and/or available OOTB.

--
Dave Abrahams           Meet me at BoostCon: http://www.boostcon.com
BoostPro Computing
http://www.boostpro.com



_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

Mark A. Hershberger
David Abrahams <[hidden email]> writes:

> 0. Looks pretty nice!

Thanks!

> 1. entering and exiting the edit mode without making changes marks the
>    buffer as modified and these changes seem to get put into the undo
>    history.  I don't think we want either of those behaviors.

Right, that is a bug.

> 2. I'd like some universal way to get back to weblogger-mode without
>    “M-x weblogger-toggle-edit-body RET”.  In fact, I'd also like to be
>    able to post new articles and update existing posts without
>    returning to weblogger.  I'm sure I can code these things up
>    myself, but if weblogger-mode is aiming to be make blogging
>    painless for Emacs users, it should make these kinds of services
>    easy and/or available OOTB.

I totally agree.  I'd like to get rid of the reliance on message-mode
entirely.  Except for editing meta information (titles, tags, dates)
there is no need for it right now.

If we had an list of methods that took a buffer from a particular mode
to some universal format and then another set that could take it from
the universal format and communicate it to a weblogging engine, that
would be almost ideal.

Then one could simply invoke, say weblogger-post-this-buffer or
weblogger-post-this-region and it (might) prompt you for a title and
tags, but the rest would be seamless.

So, for example, posting from an org-mode buffer to a weblog hosted on
Blogger.com, after invoking weblogger-post-this-buffer, weblogger jumps
into action and executes this (hypothetical) series of functions:

    weblogger-post-this-buffer
      -translate-this
        -grab-meta-information ; some modes (org-mode) have ways to
                               ; embed meta information already.
      -prompt-for-targets ; should be possible to post to multiple blogs
                          ; with one go
      -get-meta-information
         -determine-missing-meta-information
         -prompt-for-meta-information ; some blogging engines have
                                      ; different needs
      -post-to-weblog
         -post-with-atom-blogger ; to get it to blogger.com

This is just a rough idea off the top of my head, but I think this can,
as you point out, all be done without requiring a special weblogger-mode
(which was a hack from the beginning).

Mark.

--
http://hexmode.com/

The only alternative to Tradition is bad tradition.
                          — Jaraslov Pelikan


_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs
Reply | Threaded
Open this post in threaded view
|

Re: weblogger & major mode

Dave Abrahams
At Sun, 10 Jan 2010 17:20:16 -0500,
Mark A. Hershberger wrote:

>
> David Abrahams <[hidden email]> writes:
>
> > 0. Looks pretty nice!
>
> Thanks!
>
> > 1. entering and exiting the edit mode without making changes marks the
> >    buffer as modified and these changes seem to get put into the undo
> >    history.  I don't think we want either of those behaviors.
>
> Right, that is a bug.
>
> > 2. I'd like some universal way to get back to weblogger-mode without
> >    “M-x weblogger-toggle-edit-body RET”.  In fact, I'd also like to be
> >    able to post new articles and update existing posts without
> >    returning to weblogger.  I'm sure I can code these things up
> >    myself, but if weblogger-mode is aiming to be make blogging
> >    painless for Emacs users, it should make these kinds of services
> >    easy and/or available OOTB.
>
> I totally agree.  I'd like to get rid of the reliance on message-mode
> entirely.  Except for editing meta information (titles, tags, dates)
> there is no need for it right now.
>
> If we had an list of methods that took a buffer from a particular mode
> to some universal format and then another set that could take it from
> the universal format and communicate it to a weblogging engine, that
> would be almost ideal.
>
> Then one could simply invoke, say weblogger-post-this-buffer or
> weblogger-post-this-region and it (might) prompt you for a title and
> tags, but the rest would be seamless.

<schnipp>

> This is just a rough idea off the top of my head, but I think this can,
> as you point out, all be done without requiring a special weblogger-mode
> (which was a hack from the beginning).

Well I didn't actually go so far as to suggest getting rid of
weblogger mode, but of course you're right.  And your idea is probably
the right architecture in the long run.  But, FWIW, I would be very
happy with something quick, dirty, and more convenient on top of
weblogger-mode right now (hint, hint) ;-)

Thanks for all your work on this,

--
Dave Abrahams           Meet me at BoostCon: http://www.boostcon.com
BoostPro Computing
http://www.boostpro.com



_______________________________________________
Emacsweblogs mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/emacsweblogs