Re: How to get parsed output of org-eww-copy-for-org-mode ?

2019-12-25 Thread Bob Newell
I don't seem to have any trouble with org-eww-copy-for-org-mode. I
capture with a capture template. The code below may be longer or more
than you want, but it works for me.

My capture template is this:

 ("w" "Website" plain
  (function org-website-clipper)
  "* %a\n%T\n" :immediate-finish t)

And it depends on the following code.

  (require 'ol-eww)
  (require 'ol-w3m)

;;; Change this to suit:
(defvar org-website-page-archive-file "~/organize/website/websites.org")
(defun org-website-clipper ()
  "When capturing a website page, go to the right place in capture file,
   but do sneaky things. Because it's a w3m or eww page, we go
   ahead and insert the fixed-up page content, as I don't see a
   good way to do that from an org-capture template alone. Requires
   Emacs 25+ and the 2017-02-12 or later patched version of org-eww.el."
 (interactive)

;;; Address the plague of trailing whitespace in some web buffers.

 (let ((buffer-read-only nil))
  (delete-trailing-whitespace))

;;; Check for acceptable major mode (w3m or eww) and set up a couple of
;;; browser specific values. Error if unknown mode.

  (cond
   ((eq major-mode 'w3m-mode)
 (org-w3m-copy-for-org-mode))
   ((eq major-mode 'eww-mode)
 (org-eww-copy-for-org-mode))
   (t
 (error "Not valid -- must be in w3m or eww mode")))

;;; Check if we have a full path to the archive file.
;;; Create any missing directories.

  (unless (file-exists-p org-website-page-archive-file)
(let ((dir (file-name-directory org-website-page-archive-file)))
  (unless (file-exists-p dir)
(make-directory dir

  ;; Open the archive file and yank in the content.
  ;; Headers are fixed up later by org-capture.

  (find-file org-website-page-archive-file)
  (goto-char (point-max))
  ;; Leave a blank line for org-capture to fill in
  ;; with a timestamp, URL, etc.
  (insert "\n\n")
  ;; Insert the web content but keep our place.
  (save-excursion (yank))
  ;; Don't keep the page info on the kill ring.
  ;; Also fix the yank pointer.
  (setq kill-ring (cdr kill-ring))
  (setq kill-ring-yank-pointer kill-ring)
  ;; Final repositioning.
  (forward-line -1)
)



Re: refile captured to all opened Org buffer files as targets

2019-12-25 Thread Ihor Radchenko
[offtopic]

> I recently created an org-capture template for elfeed, it is finished. 

Could you share your capture template?


stardiviner  writes:

> I recently created an org-capture template for elfeed, it is finished. Now I
> have an idea is to refile it to all currently opened Org buffer files. So I
> created an function for ~org-refile-targets~ variable.
>
> #+begin_src emacs-lisp
> (defun org-refile-targets-all-files ()
>   "Use all currently opened Org buffer files as org-refile targets."
>   (mapcar 'buffer-file-name
>   (seq-filter (lambda (buffer) (if-let (file (buffer-file-name 
> buffer)) (f-ext? file "org"))) ; filter Org buffers
>   (buffer-list
> #+end_src
>
> Then set ~org-refile-targets~ to use upper custom function
>
> #+begin_src emacs-lisp :eval no
> (setq org-refile-targets '((nil :maxlevel . 3) ; current buffer headlies
>(org-agenda-files :maxlevel . 2) ; agenda files 
> headlines
>(org-refile-targets-all-files :maxlevel . 3) ; all 
> opened Org buffer files headlines
>))
> #+end_src
>
> Can I add this as a patch to Org Mode repository?
>
> -- 
> [ stardiviner ]
>I try to make every word tell the meaning what I want to express.
>
>Blog: https://stardiviner.github.io/
>IRC(freenode): stardiviner, Matrix: stardiviner
>GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
>   
>

-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong 
University, Xi'an, China
Email: yanta...@gmail.com, ihor_radche...@alumni.sutd.edu.sg



[SOLVED] Re: How to get parsed output of org-eww-copy-for-org-mode ?

2019-12-25 Thread stardiviner


Adam Porter  writes:

> You may find the package org-web-tools useful.

Thanks, Adam I found function ~org-web-tools--html-to-org-with-pandoc~ which 
can be
used in my case.

-- 
[ stardiviner ]
   I try to make every word tell the meaning what I want to express.

   Blog: https://stardiviner.github.io/
   IRC(freenode): stardiviner, Matrix: stardiviner
   GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
  



refile captured to all opened Org buffer files as targets

2019-12-25 Thread stardiviner


I recently created an org-capture template for elfeed, it is finished. Now I
have an idea is to refile it to all currently opened Org buffer files. So I
created an function for ~org-refile-targets~ variable.

#+begin_src emacs-lisp
(defun org-refile-targets-all-files ()
  "Use all currently opened Org buffer files as org-refile targets."
  (mapcar 'buffer-file-name
  (seq-filter (lambda (buffer) (if-let (file (buffer-file-name buffer)) 
(f-ext? file "org"))) ; filter Org buffers
  (buffer-list
#+end_src

Then set ~org-refile-targets~ to use upper custom function

#+begin_src emacs-lisp :eval no
(setq org-refile-targets '((nil :maxlevel . 3) ; current buffer headlies
   (org-agenda-files :maxlevel . 2) ; agenda files 
headlines
   (org-refile-targets-all-files :maxlevel . 3) ; all 
opened Org buffer files headlines
   ))
#+end_src

Can I add this as a patch to Org Mode repository?

-- 
[ stardiviner ]
   I try to make every word tell the meaning what I want to express.

   Blog: https://stardiviner.github.io/
   IRC(freenode): stardiviner, Matrix: stardiviner
   GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
  



Re: problem with org-toggle-inline-images

2019-12-25 Thread Johannes Brauer
I didn’t heard of image-mode. Perhaps I will give it a try.
But until orgmode version 9.2.6 worked  without it.


Am 24.12.2019 um 20:14 schrieb briangpowell . 
mailto:briangpowel...@gmail.com>>:

I use iimage-mode

Have you tried iimage-mode?

Notice the 2 i's in iimage

Toggling works great with iimage-mode

On Tue, Dec 24, 2019 at 8:09 AM Johannes Brauer 
mailto:bra...@nordakademie.de>> wrote:
It seems that the problem arised since I’ve upgraded orgmode from version 9.2.6 
(9.2.6-4-ge30905-elpa to version 9.3 (9.3-8-geab7c4-elpa.
On a system where the older version is installed, toggling works fine.

Johannes


Am 24.12.2019 um 11:30 schrieb Johannes Brauer 
mailto:bra...@nordakademie.de>>:

Hi Marco,

thank for your answer

Am 24.12.2019 um 11:00 schrieb Marco Wahl 
mailto:marcowahls...@gmail.com>>:

The following message is a courtesy copy of an article
that has been posted to gmane.emacs.orgmode as well.

Hi Johannes,

Thanks for the report.

Typing C-c C-x C-v the image is displayed in the org buffer
correctly. Typing C-c C-x C-v again the image does not disappear and I
get the error message:

org-toggle-inline-images: Symbol’s value as variable is void: image-map

Any hints what is going wrong?

Possibly variable image-map is not used correctly in Org or should not
be used at all.  The easiest fix would be to drop the usage of that
variable within Org, I guess.

Does the issue disappear when you do

M-: (require 'image) RET

before the image toggling?
no, the behavior remains the same.

Johannes




Re: How to get parsed output of org-eww-copy-for-org-mode ?

2019-12-25 Thread stardiviner


Adam Porter  writes:

> You may find the package org-web-tools useful.

Interesting, =org-web-tools= is useful, I will dive into source code to find 
what
is usable in my purpose.

-- 
[ stardiviner ]
   I try to make every word tell the meaning what I want to express.

   Blog: https://stardiviner.github.io/
   IRC(freenode): stardiviner, Matrix: stardiviner
   GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
  



Re: How to get parsed output of org-eww-copy-for-org-mode ?

2019-12-25 Thread Adam Porter
You may find the package org-web-tools useful.