Re: [O] Getting beginning postiion of a description list
Nicolas Richard theonewiththeevill...@yahoo.fr writes: Calvin Young calvinwyo...@gmail.com writes: How do I need to massage this to give me the beginning of the whole list item? Is there a recommended solution that'd work for both description lists *and* plain lists? This seems to work for me: (defun yf/org-beginning-of-item () (let ((element (org-element-at-point))) ;; 'plain-list is returned when at the beginning of the first item in the list. (when (eq 'plain-list (org-element-type element)) (save-excursion (forward-char) (setq element (org-element-at-point ;; look ancestors to find an 'item element. (while (and element (not (eq 'item (org-element-type element (setq element (org-element-property :parent element))) (if (not element) (error Not in a list item) (goto-char (+ (length (org-element-property :bullet element)) (org-element-property :begin element)) Probably one could use the list API directly (from org-list.el) too. Indeed, I'd definitely go for the org-list stuff. It's a bit confusing at first, because it isn't like any of the other org code, but it works well. Try calling `org-list-struct' on a list; that will probably give you most of what you need.
Re: [O] Getting beginning postiion of a description list
Hello, Calvin Young calvinwyo...@gmail.com writes: If my cursor is in a description list item, what's the recommended way of getting the point at the beginning of the description list text (i.e., after the bullet character)? To illustrate, given the following description list item, I'd like to get the point represented by the pipe character |: - |foo :: bar If I use something like `(org-element-property :contents-begin (org-element-at-point))`, that gives me the point at the beginning of the description, not the list item: - foo :: |bar How do I need to massage this to give me the beginning of the whole list item? Is there a recommended solution that'd work for both description lists *and* plain lists? See `org-special-ctrl-a/e'. Regards, -- Nicolas Goaziou
Re: [O] Getting beginning postiion of a description list
Ah, this makes sense. Unfortunately, an additional constraint I failed to mention in the first email is that it'd be nice if the solution worked for numbered lists as well. That solution unfortunately breaks on numbered lists :( Is there perhaps another way to accomplish this? P.S. I just noticed the typo in position in the subject of this thread...apols, how very embarrassing of me. On Thu, Jan 15, 2015 at 6:31 PM, John Kitchin johnrkitc...@gmail.com wrote: This is very un-orgish but it seems to do it. (forward-word) goes to the end the next recognized word, (backward-word) to the beginning of the word you are now at the end of, and (backward-char) to get to a space. You just need org to get you on the list ;) It seems to work on these. - foo :: bar(goto-char (org-element-property :contents-begin (org-element-at-point))) - baz :: goo - 1 egg - 0.5 cups - :punc #+BEGIN_SRC emacs-lisp (defun gg () (interactive) (beginning-of-line) (forward-word) (backward-word) (while (not (looking-at )) (backward-char))) #+END_SRC Calvin Young writes: Hi all, If my cursor is in a description list item, what's the recommended way of getting the point at the beginning of the description list text (i.e., after the bullet character)? To illustrate, given the following description list item, I'd like to get the point represented by the pipe character |: - |foo :: bar If I use something like `(org-element-property :contents-begin (org-element-at-point))`, that gives me the point at the beginning of the description, not the list item: - foo :: |bar How do I need to massage this to give me the beginning of the whole list item? Is there a recommended solution that'd work for both description lists *and* plain lists? Thanks everyone :) Calvin -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu
Re: [O] Getting beginning postiion of a description list
Calvin Young calvinwyo...@gmail.com writes: How do I need to massage this to give me the beginning of the whole list item? Is there a recommended solution that'd work for both description lists *and* plain lists? This seems to work for me: (defun yf/org-beginning-of-item () (let ((element (org-element-at-point))) ;; 'plain-list is returned when at the beginning of the first item in the list. (when (eq 'plain-list (org-element-type element)) (save-excursion (forward-char) (setq element (org-element-at-point ;; look ancestors to find an 'item element. (while (and element (not (eq 'item (org-element-type element (setq element (org-element-property :parent element))) (if (not element) (error Not in a list item) (goto-char (+ (length (org-element-property :bullet element)) (org-element-property :begin element)) Probably one could use the list API directly (from org-list.el) too. -- Nicolas Richard
Re: [O] Getting beginning postiion of a description list
This is very un-orgish but it seems to do it. (forward-word) goes to the end the next recognized word, (backward-word) to the beginning of the word you are now at the end of, and (backward-char) to get to a space. You just need org to get you on the list ;) It seems to work on these. - foo :: bar(goto-char (org-element-property :contents-begin (org-element-at-point))) - baz :: goo - 1 egg - 0.5 cups - :punc #+BEGIN_SRC emacs-lisp (defun gg () (interactive) (beginning-of-line) (forward-word) (backward-word) (while (not (looking-at )) (backward-char))) #+END_SRC Calvin Young writes: Hi all, If my cursor is in a description list item, what's the recommended way of getting the point at the beginning of the description list text (i.e., after the bullet character)? To illustrate, given the following description list item, I'd like to get the point represented by the pipe character |: - |foo :: bar If I use something like `(org-element-property :contents-begin (org-element-at-point))`, that gives me the point at the beginning of the description, not the list item: - foo :: |bar How do I need to massage this to give me the beginning of the whole list item? Is there a recommended solution that'd work for both description lists *and* plain lists? Thanks everyone :) Calvin -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu
[O] Getting beginning postiion of a description list
Hi all, If my cursor is in a description list item, what's the recommended way of getting the point at the beginning of the description list text (i.e., after the bullet character)? To illustrate, given the following description list item, I'd like to get the point represented by the pipe character |: - |foo :: bar If I use something like `(org-element-property :contents-begin (org-element-at-point))`, that gives me the point at the beginning of the description, not the list item: - foo :: |bar How do I need to massage this to give me the beginning of the whole list item? Is there a recommended solution that'd work for both description lists *and* plain lists? Thanks everyone :) Calvin