Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the logic may be wrong? #153

Closed
redguardtoo opened this issue Apr 25, 2014 · 7 comments
Closed

the logic may be wrong? #153

redguardtoo opened this issue Apr 25, 2014 · 7 comments

Comments

@redguardtoo
Copy link

check the code below copied from org2blog.el

              (if (re-search-forward (concat "^#\\+"
                                             (regexp-quote file-name)
                                             " ") nil t 1)
                  (setq file-web-url (buffer-substring-no-properties
                                      (point)
                                      (or (end-of-line) (point))))
                (setq file-web-url
                      (cdr (assoc "url"
                                  (metaweblog-upload-file
                                   org2blog/wp-server-xmlrpc-url
                                   org2blog/wp-server-userid
                                   org2blog/wp-server-pass
                                   org2blog/wp-server-blogid
                                   (get-file-properties file-name)))))
                (goto-char (point-max))
                (newline)
                (insert (concat "#+" file-name " " file-web-url)))
@RenWenshan
Copy link
Collaborator

I've checked this block of code, which handles the files attached in a post. So far I haven't find anything wrong. Could you please explain your thoughts further?

@redguardtoo
Copy link
Author

This is one complete if statement.

shouldn't last 4 statements be wrapped in (progn...)?

(progn
 (setq file-web-url
                      (cdr (assoc "url"
                                  (metaweblog-upload-file
                                   org2blog/wp-server-xmlrpc-url
                                   org2blog/wp-server-userid
                                   org2blog/wp-server-pass
                                   org2blog/wp-server-blogid
                                   (get-file-properties file-name)))))
                (goto-char (point-max))
                (newline)
                (insert (concat "#+" file-name " " file-web-url))
)

@RenWenshan
Copy link
Collaborator

It seems to me that the outer progn has taken care of them (I might misunderstand progn though).

(progn
          (goto-char (point-min))
          (if (re-search-forward (concat "^#\\+"
                                         (regexp-quote file-name)
                                         " ") nil t 1)
              (setq file-web-url (buffer-substring-no-properties
                                  (point)
                                  (or (end-of-line) (point))))
            (setq file-web-url
                  (cdr (assoc "url"
                              (metaweblog-upload-file
                               org2blog/wp-server-xmlrpc-url
                               org2blog/wp-server-userid
                               org2blog/wp-server-pass
                               org2blog/wp-server-blogid
                               (get-file-properties file-name)))))
            (goto-char (point-max))
            (newline)
            (insert (concat "#+" file-name " " file-web-url)))
          (setq file-all-urls
                (append file-all-urls (list (cons
                                             file-name file-web-url)))))

@redguardtoo
Copy link
Author

(setq file-web-url
(cdr (assoc "url"
(metaweblog-upload-file
org2blog/wp-server-xmlrpc-url
org2blog/wp-server-userid
org2blog/wp-server-pass
org2blog/wp-server-blogid
(get-file-properties file-name)))))
(goto-char (point-max))
(newline)
(insert (concat "#+" file-name " " file-web-url))

These 4 lines exists in an "if" statement. Is this desired logic?

On Tue, May 6, 2014 at 8:01 PM, Wenshan [email protected] wrote:

(setq file-web-url (cdr (assoc "url" (metaweblog-upload-file
org2blog/wp-server-xmlrpc-url org2blog/wp-server-userid
org2blog/wp-server-pass org2blog/wp-server-blogid (get-file-properties
file-name))))) (goto-char (point-max)) (newline) (insert (concat "#+"
file-name " " file-web-url))

help me, help you.

@RenWenshan
Copy link
Collaborator

I see what you mean, good point.

  1. (info "(elisp) Sequencing") returns:

    ...
    In the early days of Lisp, ‘progn’ was the only way to execute two or
    more forms in succession and use the value of the last of them. But
    programmers found they often needed to use a ‘progn’ in the body of a
    function, where (at that time) only one form was allowed. So the body
    of a function was made into an “implicit ‘progn’”: several forms are
    allowed just as in the body of an actual ‘progn’. Many other control
    structures likewise contain an implicit ‘progn’. As a result, ‘progn’
    is not used as much as it was many years ago. It is needed now most
    often inside an ‘unwind-protect’, ‘and’, ‘or’, or in the THEN-part of an
    ‘if’.
    ....

In the last sentence of the above paragraph, it mentions that the then-part of an 'if' should be inside a progn.

  1. (info "(elisp) Conditionals") returns:

    -- Special Form: if condition then-form else-forms…

Therefore I think the lines you mentioned are actually in the else-forms, which doesn't require its content to be placed in a progn.

What do you think?

@redguardtoo
Copy link
Author

Yes, got

On Wed, May 7, 2014 at 10:49 AM, Wenshan [email protected] wrote:

I see what you mean, good point.

(info "(elisp) Sequencing") returns:

...
In the early days of Lisp, ‘progn’ was the only way to execute two or
more forms in succession and use the value of the last of them. But
programmers found they often needed to use a ‘progn’ in the body of a
function, where (at that time) only one form was allowed. So the body
of a function was made into an “implicit ‘progn’”: several forms are
allowed just as in the body of an actual ‘progn’. Many other control
structures likewise contain an implicit ‘progn’. As a result, ‘progn’
is not used as much as it was many years ago. It is needed now most
often inside an ‘unwind-protect’, ‘and’, ‘or’, or in the THEN-part of an
‘if’.
....

In the last sentence of the above paragraph, it mentions that the
then-part of an 'if' should be inside a progn.

(info "(elisp) Conditionals") returns:

-- Special Form: if condition then-form else-forms…

Therefore I think the lines you mentioned are actually in the
else-forms, which doesn't require its content to be placed in a progn.

What do you think?


Reply to this email directly or view it on GitHubhttps://github.com//issues/153#issuecomment-42384340
.

help me, help you.

@RenWenshan
Copy link
Collaborator

Can I close this issue?
On May 7, 2014 12:57 PM, "chen bin" [email protected] wrote:

Yes, got

On Wed, May 7, 2014 at 10:49 AM, Wenshan [email protected]
wrote:

I see what you mean, good point.

(info "(elisp) Sequencing") returns:

...
In the early days of Lisp, ‘progn’ was the only way to execute two or
more forms in succession and use the value of the last of them. But
programmers found they often needed to use a ‘progn’ in the body of a
function, where (at that time) only one form was allowed. So the body
of a function was made into an “implicit ‘progn’”: several forms are
allowed just as in the body of an actual ‘progn’. Many other control
structures likewise contain an implicit ‘progn’. As a result, ‘progn’
is not used as much as it was many years ago. It is needed now most
often inside an ‘unwind-protect’, ‘and’, ‘or’, or in the THEN-part of an
‘if’.
....

In the last sentence of the above paragraph, it mentions that the
then-part of an 'if' should be inside a progn.

(info "(elisp) Conditionals") returns:

-- Special Form: if condition then-form else-forms…

Therefore I think the lines you mentioned are actually in the
else-forms, which doesn't require its content to be placed in a progn.

What do you think?


Reply to this email directly or view it on GitHub<
https://github.com/punchagan/org2blog/issues/153#issuecomment-42384340>
.

help me, help you.


Reply to this email directly or view it on GitHubhttps://github.com//issues/153#issuecomment-42384732
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants