Re: [PATCH] ob-sql.el: Add support for SAP HANA

2021-03-09 Thread Robin Campbell Joy
Hi,

could someone please let me know if something is missing/incorrect?
If everything should be fine, is there anything still required from my side
to include this patch? I couldn't find anything else in the contributor
guide.

Thanks and best regards,
Robin

On Thu, 4 Feb 2021 at 08:55, Robin Campbell Joy  wrote:

> * lisp/ob-sql.el (org-babel-execute:sql, org-babel-sql-dbstring-saphana):
> Add basic support for SAP HANA to SQL blocks
> * testing/lisp/test-ob-sql.el: Basic tests for generated db connection
> string
>
> This change adds basic support for SAP HANA to SQL blocks by
> specifying saphana as :engine.
>
> It also adds a new header arg `dbinstance' in order to specify the SAP
> HANA instance to connect to.
>
> Signed-off-by: Robin Campbell Joy 
> ---
>  lisp/ob-sql.el  |  25 ++-
>  testing/lisp/test-ob-sql.el | 382 
>  2 files changed, 406 insertions(+), 1 deletion(-)
>  create mode 100644 testing/lisp/test-ob-sql.el
>
> diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
> index 902194ae8..5398c85aa 100644
> --- a/lisp/ob-sql.el
> +++ b/lisp/ob-sql.el
> @@ -40,6 +40,7 @@
>  ;; - dbuser
>  ;; - dbpassword
>  ;; - dbconnection (to reference connections in sql-connection-alist)
> +;; - dbinstance
>  ;; - database
>  ;; - colnames (default, nil, means "yes")
>  ;; - result-params
> @@ -58,6 +59,7 @@
>  ;; - postgresql (postgres)
>  ;; - oracle
>  ;; - vertica
> +;; - saphana
>  ;;
>  ;; TODO:
>  ;;
> @@ -85,6 +87,7 @@
>  (dbport   . :any)
>  (dbuser   . :any)
>  (dbpassword   . :any)
> +(dbinstance   . :any)
>  (database   . :any))
>"SQL-specific header arguments.")
>
> @@ -174,6 +177,18 @@ SQL Server on Windows and Linux platform."
>(when database (format "-d %s" database
>" "))
>
> +(defun org-babel-sql-dbstring-saphana (host port instance user password
> database)
> +  "Make SAP HANA command line args for database connection. Pass nil to
> omit that arg."
> +  (mapconcat #'identity
> + (delq nil
> +   (list (when (and host port) (format "-n %s:%s" host
> port))
> + (when (and host (not port)) (format "-n %s"
> host))
> + (when instance (format "-i %d" instance))
> + (when user (format "-u %s" user))
> + (when password (format "-p %s"
> (shell-quote-argument password)))
> + (when database (format "-d %s" database
> + " "))
> +
>  (defun org-babel-sql-convert-standard-filename (file)
>"Convert FILE to OS standard file name.
>  If in Cygwin environment, uses Cygwin specific function to
> @@ -197,6 +212,7 @@ database connections."
>   (:dbport . sql-port)
>   (:dbuser . sql-user)
>   (:dbpassword . sql-password)
> + (:dbinstance . sql-dbinstance)
>   (:database . sql-database)))
>   (mapped-name (cdr (assq name name-mapping
>  (cadr (assq mapped-name
> @@ -212,6 +228,7 @@ This function is called by
> `org-babel-execute-src-block'."
>   (dbport (org-babel-find-db-connection-param params :dbport))
>   (dbuser (org-babel-find-db-connection-param params :dbuser))
>   (dbpassword (org-babel-find-db-connection-param params
> :dbpassword))
> + (dbinstance (org-babel-find-db-connection-param params
> :dbinstance))
>   (database (org-babel-find-db-connection-param params :database))
>   (engine (cdr (assq :engine params)))
>   (colnames-p (not (equal "no" (cdr (assq :colnames params)
> @@ -276,6 +293,12 @@ footer=off -F \"\t\"  %s -f %s -o %s %s"
>dbhost dbport dbuser dbpassword database)
>   (org-babel-process-file-name in-file)
>   (org-babel-process-file-name out-file)))
> +(saphana (format "hdbsql %s -I %s -o %s %s"
> + (org-babel-sql-dbstring-saphana
> +  dbhost dbport dbinstance dbuser dbpassword database)
> + (org-babel-process-file-name in-file)
> + (org-babel-process-file-name out-file)
> + (or cmdline "")))
>  (t (user-error "No support for the %s SQL engine"
> engine)
>  (with-temp-file in-file
>(insert
> @@ -309,7 +332,7 @@ SET COLSEP '|'
>   (progn (insert-file-contents-literally out-file) (buffer-string)))
>(with-temp-buffer
>   (cond
> - ((memq (intern engine) '(dbi mysql postgresql postgres sqsh vertica))
> + ((memq (intern engine) '(dbi mysql postgresql postgres saphana sqsh
> vertica))
>;; Add header row delimiter after column-names header in first line
>(cond
> (colnames-p
> diff --git a/testing/lisp/test-ob-sql.el b/testing/lisp/test-ob-sql.el
> new file mode 100644
> index 0..51edd2309
> --- /dev/null
> +++ b/testing/lisp/test-ob-sql.el
> @@ -0,0 +1,382 @@
> +;;; test-ob-sql.el --- tests for ob-sql.el

Re: Problem with org-ref

2021-03-09 Thread Kyle Meyer
Marvin M. Doyley writes:

> Hi there,
>
> When I use crossref-add-bibtex-entry it download the BibTeX entry but cannot 
> download the associated pdf.
> I get the following error  (wrong-type-argument stringp 
> ("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/“))
>
> I configured org-ref as follows
>
> (setq org-ref-bibliography-notes 
> '("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/ref_notes.org") 
>   org-ref-default-bibliography 
> '("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/ref.bib") 
>   org-ref-pdf-directory 
> '("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/")
> org-ref-notes-citation-link '("cite")
>   )

[ Caveat: I've never used org-ref ]

org-ref's 0383cc2 (support multiple pdf directories, 2016-06-10) updated
org-ref-pdf-directory to accept a list value, so your value is valid,
but...

> Debugger entered--Lisp error: (wrong-type-argument stringp 
> ("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/"))
>   file-name-as-directory(("/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/"))
>   doi-utils-get-bibtex-entry-pdf(nil)

... doi-utils-get-bibtex-entry-pdf wasn't updated for that (+cc the
author of that commit and John Kitchin).

It looks like org-ref-pdf-directory still supports a string, though, and
you only have one item, so you should be able to work around the issue
with

  (setq org-ref-pdf-directory 
"/Users/doyley/Dropbox/Filing_Cabinet/B/refs/pdf/")



Re: Bug: 28.0.50; `org-clocking-buffer` definition was removed, but it is still being referenced [9.4.3]

2021-03-09 Thread Kyle Meyer
Eduardo Bellani writes:

> Kyle Meyer writes:
>
>> In 16b5ee0ef, org-clocking-buffer was moved from org-clock.el to org.el,
>> and org-clock.el loads org.el.
>>
>> What's the concrete problem that you're running into?

> Backtrace:
>
> Debugger entered--Lisp error: (void-function org-clocking-buffer)
>   org-clocking-buffer()
>   org-clocking-p()
>   org-clock-in(nil)
>   funcall-interactively(org-clock-in nil)
>   call-interactively(org-clock-in nil nil)
>   command-execute(org-clock-in)

My guess is that you either have a stale org.elc file or have a mixed
installation with an old org.el shadowing the new one.  If the issue
doesn't go away after removing/regenerating the elc files,
list-load-path-shadows might reveal the problem.

https://orgmode.org/worg/org-faq.html#mixed-install



Re: Using lexical-binding

2021-03-09 Thread Kyle Meyer
Stefan Monnier writes:

> Any chance you could put this in the `Package-Requires:`?

Sure, added (5263eff5a).

> Note that all the uses I introduced of `with-suppressed-warnings` only
> wrap a very small amount of code, so you could also replace them with
> `with-no-warnings` (added back in Emacs-22).

Good point.  I've switched to using with-suppressed-warnings and applied
the patch to master (129c33ddd).

Thanks again.



Re: Bug: 28.0.50; `org-clocking-buffer` definition was removed, but it is still being referenced [9.4.3]

2021-03-09 Thread Eduardo Bellani
Backtrace:


Debugger entered--Lisp error: (void-function org-clocking-buffer)
  org-clocking-buffer()
  org-clocking-p()
  org-clock-in(nil)
  funcall-interactively(org-clock-in nil)
  call-interactively(org-clock-in nil nil)
  command-execute(org-clock-in)

Kyle Meyer writes:

> Eduardo Bellani writes:
>
>> On 16b5ee0efb5592f78faeffa07048bfe741331a18 `org-clocking-buffer` was
>> removed as a symbol. That symbol is still being referenced throughout
>> the current(4d463ee4baf8a7ce8b7c633149a9452bc70ef557) `org-clock.el`
>> file.
>
> In 16b5ee0ef, org-clocking-buffer was moved from org-clock.el to org.el,
> and org-clock.el loads org.el.
>
> What's the concrete problem that you're running into?


--
Eduardo Bellani -- datarisk.io


signature.asc
Description: PGP signature


Re: org-capture-templates: %date is too long

2021-03-09 Thread Robert Pluim
> On Thu, 04 Mar 2021 21:24:03 +0100, Uwe Brauer  said:

Uwe> I am not acquainted with let-bound (only with let)

'let-bound' is a shorthand for saying 'binding a value using let'

Uwe> So are you saying I should may use defadvice to modify org-capture?

Well, you have control over how org-capture is invoked, so you could
do:

(defun my-org-capture ()
   (let ((org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a>")))
(org-capture)))

although you could do it with advice if you wanted. Untested, of course :-)

Robert
-- 



Re: Using lexical-binding

2021-03-09 Thread Stefan Monnier
Hi Kyle,

>> Subject: [PATCH] * lisp/org-agenda.el: Use lexical-binding
> [...]
>> +(pcase type
>> +  ('agenda
>> +   (org-agenda-list current-prefix-arg))
>
> Unfortunately Org's minimum Emacs version is still Emacs 24.3.

Sorry 'bout that.  I keep forgetting about this detail of `pcase` past.
Any chance you could put this in the `Package-Requires:`?

>> +  (let* ((gprops (nth 1 series))
>> + (gvars (mapcar #'car gprops))
>> + (gvals (mapcar (lambda (binding) (eval (cadr binding) t)) gprops)))
>> +(cl-progv gvars gvals (org-agenda-prepare name))
>> +;; We need to reset agenda markers here, because when constructing a
>> +;; block agenda, the individual blocks do not do that.
>> +(org-agenda-reset-markers)
>> +(with-suppressed-warnings ((lexical match))
>
> ... I believe with-suppressed-warnings isn't available until Emacs 27.1,
> right?

Ooh, right, and that is not just a little detail, I very much know
about that.  I don't have any excuse for this one (it's just
a careless copy).

> Any objections to me squashing the below changes into your patch?

Of course not.

> +(if (fboundp 'with-suppressed-warnings)  ; Introduced in Emacs 27.1.
> +(defalias 'org-with-suppressed-warnings 'with-suppressed-warnings)
> +  (defmacro org-with-suppressed-warnings (_warnings  body)
> +(declare (debug (sexp  body)) (indent 1))
> +`(progn ,@body)))

Note that all the uses I introduced of `with-suppressed-warnings` only
wrap a very small amount of code, so you could also replace them with
`with-no-warnings` (added back in Emacs-22).


Stefan




Re: org-refile failed due to default option stored by org-goto

2021-03-09 Thread Maxim Nikulin

On 05/03/2021 05:53, Samuel Wales wrote:

diff --git a/lisp/org-refile.el b/lisp/org-refile.el
index 1e6872b46..8f98e9cf9 100644
--- a/lisp/org-refile.el
+++ b/lisp/org-refile.el
@@ -617,7 +617,9 @@ this function appends the default value from
 (tbl (mapcar
   (lambda (x)
 (if (and (not (member org-refile-use-outline-path
-  '(file full-file-path)))
+   ;; === alpha remove the parens
from ido completion of olpaths
+  '(nil full-file-path)))
+  ;; '(file full-file-path)))
  (not (equal filename (nth 1 x
 (cons (concat (car x) extra " ("
   (file-name-nondirectory (nth 1 x)) ")")


The patch changes appearance of "(file.org)" at the end of each 
completion option. I do not know value of your 
org-refile-use-outline-path setting so I am unsure if your are trying to 
avoid it or vice versa to force it.


I do not think that the patch is relevant to sharing of default option 
between org-goto and org-refile. I think, buffer (or file) name should 
be stored separately from outline path within the buffer in org-refile 
history and merged accordingly to current settings just before 
completing-read. org-refile-cache likely requires a similar approach.


Personally I was confused by behavior of (org-refile-use-outline-path 
t). Completion options appears as "A (file.org)", "A/B (file.org)", and 
I could not figure out how to refile directly to "A" headings. I suspect 
that org-refile-allow-creating-parent-nodes does not work with "t" at 
all. Recently I have realized that after typing of "A/B" TAB completes 
option to "A/B (file.org)" and I was trying RET after "A". It is 
necessary to add space "A " to refile to a non-leaf node.


That was the reason why I set (org-refile-use-outline-path 'file). 
Completion options appears as "file.org/A/B". I have to press TAB at 
first to get "file.org/" but then after "file.org/A" RET works fine.






Re: overloading of internal priority calculations in agenda

2021-03-09 Thread Adam Spiers
Thanks Jack for the helpful response and support of my assessment.

I do intend to fix this as part of my ongoing (but currently delayed)
work on improving agenda sorting and adding an option to manually sort.

On Tue, 9 Mar 2021 at 07:07, Jack Kamm  wrote:
>
> Hi Adam,
>
> > I further noticed that this overloading of the internal priority by
> > including timestamp and habit data causes disruption to the behaviour
> > I imagine most users would expect from `org-agenda-sorting-strategy'.
> > For example, if you have `priority-down' as the first entry in the
> > `agenda' section and `category-keep' as the second, then differences
> > in the SCHEDULED timestamp are included in the priority calculation
> > and can therefore prevent sorting of two adjacent [#B] items by
> > category.  This seems like a bug to me, or at least breaks the
> > Principle of Least Surprise.
>
> I just ran into this issue you highlight here.
>
> In particular, I was trying to set the org-agenda-sorting-strategy to
>
> (priority-down scheduled-down)
>
> i.e., sorting by priority (highest first), and then within priority,
> sorting by scheduled (most recent first).
>
> However, the fact that the priority includes the scheduled timestamp
> makes this sorting strategy impossible.
>
> I agree this seems like a bug, in that it contradicts the written
> documentation as far as I can tell (for example, the *Help* for
> org-agenda-sorting-strategy mentions nothing of the fact that the
> priority includes the scheduled timestamp, and I don't see anything
> about it in the *Info* either).
>
> I imagine that many have gotten used to the default behavior of sort by
> highest priority, then by earliest scheduled timestamp, but we could
> keep this default behavior by adding "scheduled-up" after
> "priority-down" in org-agenda-sorting-strategy, as you allude.
>
> Jack