enhancement: keybindings to navigate to header fields #20

Closed
titaniumbones opened this Issue Nov 1, 2010 · 5 comments

Projects

None yet

2 participants

@titaniumbones
Collaborator

it would be nice to be able to navigate directly to the title, category, etc. headers in an org2blog buffer. something similar is done by the ancient post.el mode i used to use with mutt:

(defun header-position-on-value ()
"Go to the start of the value part of a header."
(beginning-of-line)
(skip-chars-forward "-A-Za-z0-9:")
;; XXX - Should make sure we stay on line.
(forward-char)
(point))

(defun header-goto-field (field)
"Go to FIELD of a header."
(let ((case-fold-search t))
(goto-char (point-min))
(save-match-data
(when (re-search-forward (concat "^($|" field ": )"))
(if (looking-at "^$")
(progn
(insert-string field ": \n")
(forward-char -1))
(header-position-on-value))))))

(defmacro define-header-goto (name header)
"Define functions called NAME to go to HEADER."
`(defun ,name ()
,(concat "Position the cursor on the " header ": header.")
(interactive)
(header-goto-field ,header)))

(define-header-goto header-goto-to "To")
(define-header-goto header-goto-cc "Cc")
(define-header-goto header-goto-fcc "Fcc")
(define-header-goto header-goto-summary "Summary")
(define-header-goto header-goto-keywords "Keywords")
(define-header-goto header-goto-subject "Subject")
(define-header-goto header-goto-bcc "Bcc")
(define-header-goto header-goto-reply-to "Reply-To")
(define-header-goto header-goto-from "From")

(define-header-goto header-goto-organization "Organization")

my regex parsing is poor esp. in lisp but something like this shd work i think:

  •  (when (re-search-forward (concat "^\($\|" field ": \)"))
    
  •  (when (re-search-forward (concat "^\($\|+#" field ": \)"))
    

& then define appropriate functions and keybindings -- i'm not sure, what do you think would be good values for the latter?

as i say, wishlist only.
matt

@punchagan
Owner

Thanks for the idea. I like it.
Do you think it would be nice to propose this for org-mode? (Org-mode already has completion for the headers with M-TAB and this works in org2blog, too obviously)

@titaniumbones
Collaborator

hmm, that does sound like good idea. if i haven't proposed this on the list in 2 weeks get back to me? I'm a bit strung out writing a grant proposal till the 23rd. thanks, best,
matt

@punchagan
Owner

Ok! Sounds good!

@punchagan
Owner

Just a reminder. :)

@punchagan
Owner

Closing as won't fix for now.
Feel free to re-open, though.

@punchagan punchagan closed this May 26, 2014
@punchagan punchagan added the wont-fix label May 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment