unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Multiline Comments
@ 2020-11-08 20:47 Christopher Dimech
  2020-11-09  9:28 ` Jean Louis
  2020-11-09 10:10 ` Michael Heerdegen
  0 siblings, 2 replies; 17+ messages in thread
From: Christopher Dimech @ 2020-11-08 20:47 UTC (permalink / raw)
  To: Help Gnu Emacs

Have included the following macro for writing multiline comments

(defmacro multic (&rest _) nil)


But the thing complains when writing

(multic
#+STARTUP: content
* Adds Directories to load-path and the Melpa Package Archives)




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-08 20:47 Multiline Comments Christopher Dimech
@ 2020-11-09  9:28 ` Jean Louis
  2020-11-09 13:01   ` Michael Heerdegen
  2020-11-09 10:10 ` Michael Heerdegen
  1 sibling, 1 reply; 17+ messages in thread
From: Jean Louis @ 2020-11-09  9:28 UTC (permalink / raw)
  To: Christopher Dimech; +Cc: Help Gnu Emacs

I wish I could understand how that macro works for multi line
comments. 

* Christopher Dimech <dimech@gmx.com> [2020-11-08 23:48]:
> Have included the following macro for writing multiline comments
> 
> (defmacro multic (&rest _) nil)
> 
> 
> But the thing complains when writing
> 
> (multic
> #+STARTUP: content
> * Adds Directories to load-path and the Melpa Package Archives)



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-08 20:47 Multiline Comments Christopher Dimech
  2020-11-09  9:28 ` Jean Louis
@ 2020-11-09 10:10 ` Michael Heerdegen
  2020-11-09 12:14   ` Christopher Dimech
  1 sibling, 1 reply; 17+ messages in thread
From: Michael Heerdegen @ 2020-11-09 10:10 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Dimech <dimech@gmx.com> writes:

> Have included the following macro for writing multiline comments
>
> (defmacro multic (&rest _) nil)
>
>
> But the thing complains when writing
>
> (multic
>
> #+STARTUP: content
> * Adds Directories to load-path and the Melpa Package Archives)

Yes indeed, such a macro will only allow to "comment" `read'able
symbolic Elisp expressions.

Even then it has another downside: even though the arguments are
ignored, the macro expression will still be evaluated and return
something (nil), so it may change the semantics of a surrounding form.

Why do you want to avoid commenting with ";" btw?

Regards,

Michael.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 10:10 ` Michael Heerdegen
@ 2020-11-09 12:14   ` Christopher Dimech
  2020-11-09 13:29     ` Joost Kremers
  0 siblings, 1 reply; 17+ messages in thread
From: Christopher Dimech @ 2020-11-09 12:14 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs




> Sent: Monday, November 09, 2020 at 11:10 AM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Multiline Comments
>
> Christopher Dimech <dimech@gmx.com> writes:
>
> > Have included the following macro for writing multiline comments
> >
> > (defmacro multic (&rest _) nil)
> >
> >
> > But the thing complains when writing
> >
> > (multic
> >
> > #+STARTUP: content
> > * Adds Directories to load-path and the Melpa Package Archives)
>
> Yes indeed, such a macro will only allow to "comment" `read'able
> symbolic Elisp expressions.
>
> Even then it has another downside: even though the arguments are
> ignored, the macro expression will still be evaluated and return
> something (nil), so it may change the semantics of a surrounding form.
>
> Why do you want to avoid commenting with ";" btw?

Because I want to pass the file through Org-Mode and Rec-Utils, which
require Org and Rec Commands to start at the beginning of the line.

My workaround has been to include the commands within Double Quotes.

(multic "
#+STARTUP: content
* Adds Directories to load-path and the Melpa Package Archives")

But it would help if we can think of an improvement to multic, thus
looking for ideas I can try.

>
> Regards,
>
> Michael.
>
>
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09  9:28 ` Jean Louis
@ 2020-11-09 13:01   ` Michael Heerdegen
  2020-11-09 13:18     ` Christopher Dimech
  0 siblings, 1 reply; 17+ messages in thread
From: Michael Heerdegen @ 2020-11-09 13:01 UTC (permalink / raw)
  To: help-gnu-emacs

Jean Louis <bugs@gnu.support> writes:

> > (defmacro multic (&rest _) nil)

> I wish I could understand how that macro works for multi line
> comments. 

The macro lets evaluation ignore all enclosed expressions.  A similar
effect can be reached by quoting lop-level expressions.  That's already
all.

If what is enclosed is not a set of valid expressions, you
get... problems.



Michael.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 13:01   ` Michael Heerdegen
@ 2020-11-09 13:18     ` Christopher Dimech
  2020-11-09 13:33       ` Joost Kremers
  0 siblings, 1 reply; 17+ messages in thread
From: Christopher Dimech @ 2020-11-09 13:18 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs



> Sent: Monday, November 09, 2020 at 2:01 PM
> From: "Michael Heerdegen" <michael_heerdegen@web.de>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Multiline Comments
>
> Jean Louis <bugs@gnu.support> writes:
>
> > > (defmacro multic (&rest _) nil)
>
> > I wish I could understand how that macro works for multi line
> > comments.
>
> The macro lets evaluation ignore all enclosed expressions.  A similar
> effect can be reached by quoting lop-level expressions.  That's already
> all.
>
> If what is enclosed is not a set of valid expressions, you
> get... problems.

Correct - The problem crops up because expressions still got to be valid.
I resolve the problem, I use double quotes, so that elisp would consider
the comment lines as common strings.  Is there a way to construct a macro
or function to disregard the requirement for valid expressions, because
one can write whatever one wants in comments.


>
>
> Michael.
>
>
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 12:14   ` Christopher Dimech
@ 2020-11-09 13:29     ` Joost Kremers
  0 siblings, 0 replies; 17+ messages in thread
From: Joost Kremers @ 2020-11-09 13:29 UTC (permalink / raw)
  To: help-gnu-emacs


On Mon, Nov 09 2020, Christopher Dimech wrote:
> Because I want to pass the file through Org-Mode and Rec-Utils, which
> require Org and Rec Commands to start at the beginning of the line.
>
> My workaround has been to include the commands within Double Quotes.
>
> (multic "
> #+STARTUP: content
> * Adds Directories to load-path and the Melpa Package Archives")
>
> But it would help if we can think of an improvement to multic, thus
> looking for ideas I can try.

Have you considered other ways of achieving what you want? You can include code
snippets in Org documents, which can be executed from within the document, or
exported to create a source-only file. The Org manual, section "Working with
source code" has all the details.

And there's also the [lentic](https://github.com/phillord/lentic) package, which
makes it possible to have two different, related versions of a file. See the
website for some examples.

Perhaps you've already considered those options, but if not, they both seem more
flexible and powerful than what you're trying.

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 13:18     ` Christopher Dimech
@ 2020-11-09 13:33       ` Joost Kremers
  2020-11-09 13:55         ` Christopher Dimech
  0 siblings, 1 reply; 17+ messages in thread
From: Joost Kremers @ 2020-11-09 13:33 UTC (permalink / raw)
  To: help-gnu-emacs


On Mon, Nov 09 2020, Christopher Dimech wrote:
> Correct - The problem crops up because expressions still got to be valid.
> I resolve the problem, I use double quotes, so that elisp would consider
> the comment lines as common strings.  Is there a way to construct a macro
> or function to disregard the requirement for valid expressions, because
> one can write whatever one wants in comments.

No, because what's causing problems is the reader, i.e., the part of the Lisp
system that converts the textual representation of Lisp code into the system's
internal representation of Lisp code. In Elisp, you cannot intervene in this
process, so there's no way to construct a macro that does what you want.

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 13:33       ` Joost Kremers
@ 2020-11-09 13:55         ` Christopher Dimech
  2020-11-09 14:37           ` Joost Kremers
  0 siblings, 1 reply; 17+ messages in thread
From: Christopher Dimech @ 2020-11-09 13:55 UTC (permalink / raw)
  To: Joost Kremers; +Cc: help-gnu-emacs

> Sent: Monday, November 09, 2020 at 2:33 PM
> From: "Joost Kremers" <joostkremers@fastmail.fm>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Multiline Comments
>
>
> On Mon, Nov 09 2020, Christopher Dimech wrote:
> > Correct - The problem crops up because expressions still got to be valid.
> > I resolve the problem, I use double quotes, so that elisp would consider
> > the comment lines as common strings.  Is there a way to construct a macro
> > or function to disregard the requirement for valid expressions, because
> > one can write whatever one wants in comments.
>
> No, because what's causing problems is the reader, i.e., the part of the Lisp
> system that converts the textual representation of Lisp code into the system's
> internal representation of Lisp code. In Elisp, you cannot intervene in this
> process, so there's no way to construct a macro that does what you want.

Fair enough.  I am currently making comments using a string.  This does not make
Elisp complain.

(multic "
Any Comment")

I would then think you would use a function or a variable?


>
> --
> Joost Kremers
> Life has its moments
>
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 13:55         ` Christopher Dimech
@ 2020-11-09 14:37           ` Joost Kremers
  2020-11-09 15:08             ` Christopher Dimech
  0 siblings, 1 reply; 17+ messages in thread
From: Joost Kremers @ 2020-11-09 14:37 UTC (permalink / raw)
  To: help-gnu-emacs


On Mon, Nov 09 2020, Christopher Dimech wrote:
> Fair enough.  I am currently making comments using a string.  This does not make
> Elisp complain.

Well, strings are Lisp objects, so they are OK. But be careful with using double
quotes in your comments: they'll need to be escaped.

Still, the other problem that Michael pointed out still stands: `multic' returns
a value (specifically nil), which may cause problems. You'll need to be careful
where you use it.

> I would then think you would use a function or a variable?

Not sure what you mean by that. Use where? For what purpose?

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 14:37           ` Joost Kremers
@ 2020-11-09 15:08             ` Christopher Dimech
  2020-11-09 15:23               ` Joost Kremers
  0 siblings, 1 reply; 17+ messages in thread
From: Christopher Dimech @ 2020-11-09 15:08 UTC (permalink / raw)
  To: Joost Kremers; +Cc: help-gnu-emacs


> Sent: Monday, November 09, 2020 at 3:37 PM
> From: "Joost Kremers" <joostkremers@fastmail.fm>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Multiline Comments
>
>
> On Mon, Nov 09 2020, Christopher Dimech wrote:
> > Fair enough.  I am currently making comments using a string.  This does not make
> > Elisp complain.
>
> Well, strings are Lisp objects, so they are OK. But be careful with using double
> quotes in your comments: they'll need to be escaped.

My comments are not very complicated.  But, you are correct, I then got to
escape double quotes inside strings.

> Still, the other problem that Michael pointed out still stands: `multic' returns
> a value (specifically nil), which may cause problems. You'll need to be careful
> where you use it.
>
> > I would then think you would use a function or a variable?
>
> Not sure what you mean by that. Use where? For what purpose?

To define a variable or a function to avoid some of the problems that occur with multic.

>
> --
> Joost Kremers
> Life has its moments
>
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 15:08             ` Christopher Dimech
@ 2020-11-09 15:23               ` Joost Kremers
  2020-11-09 15:35                 ` Christopher Dimech
  2020-11-09 17:51                 ` Christopher Dimech
  0 siblings, 2 replies; 17+ messages in thread
From: Joost Kremers @ 2020-11-09 15:23 UTC (permalink / raw)
  To: help-gnu-emacs


On Mon, Nov 09 2020, Christopher Dimech wrote:
>> > I would then think you would use a function or a variable?
>>
>> Not sure what you mean by that. Use where? For what purpose?
>
> To define a variable or a function to avoid some of the problems that occur with multic.

Unfortunately, no. There's simply no way to do what you want. That's why I
suggested you look at source blocks in Org mode and/or lentic.

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 15:23               ` Joost Kremers
@ 2020-11-09 15:35                 ` Christopher Dimech
  2020-11-09 19:01                   ` Joost Kremers
  2020-11-09 17:51                 ` Christopher Dimech
  1 sibling, 1 reply; 17+ messages in thread
From: Christopher Dimech @ 2020-11-09 15:35 UTC (permalink / raw)
  To: Joost Kremers; +Cc: help-gnu-emacs


> Sent: Monday, November 09, 2020 at 4:23 PM
> From: "Joost Kremers" <joostkremers@fastmail.fm>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Multiline Comments
>
>
> On Mon, Nov 09 2020, Christopher Dimech wrote:
> >> > I would then think you would use a function or a variable?
> >>
> >> Not sure what you mean by that. Use where? For what purpose?
> >
> > To define a variable or a function to avoid some of the problems that occur with multic.
>
> Unfortunately, no. There's simply no way to do what you want. That's why I
> suggested you look at source blocks in Org mode and/or lentic.

Org Source Blocks won't work as the files are Elisp Files for customising Emacs.
Got to look at Lentic, see what's that about.

Many Thanks Joost

> --
> Joost Kremers
> Life has its moments
>
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 15:23               ` Joost Kremers
  2020-11-09 15:35                 ` Christopher Dimech
@ 2020-11-09 17:51                 ` Christopher Dimech
  1 sibling, 0 replies; 17+ messages in thread
From: Christopher Dimech @ 2020-11-09 17:51 UTC (permalink / raw)
  To: Joost Kremers; +Cc: help-gnu-emacs

Which one do you think would be least problematic?


> Sent: Monday, November 09, 2020 at 4:23 PM
> From: "Joost Kremers" <joostkremers@fastmail.fm>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Multiline Comments
>
>
> On Mon, Nov 09 2020, Christopher Dimech wrote:
> >> > I would then think you would use a function or a variable?
> >>
> >> Not sure what you mean by that. Use where? For what purpose?
> >
> > To define a variable or a function to avoid some of the problems that occur with multic.
>
> Unfortunately, no. There's simply no way to do what you want. That's why I
> suggested you look at source blocks in Org mode and/or lentic.
>
> --
> Joost Kremers
> Life has its moments
>
>



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 15:35                 ` Christopher Dimech
@ 2020-11-09 19:01                   ` Joost Kremers
  2020-11-10  0:13                     ` Robert Thorpe
  0 siblings, 1 reply; 17+ messages in thread
From: Joost Kremers @ 2020-11-09 19:01 UTC (permalink / raw)
  To: help-gnu-emacs


On Mon, Nov 09 2020, Christopher Dimech wrote:
> Org Source Blocks won't work as the files are Elisp Files for customising Emacs.
> Got to look at Lentic, see what's that about.

Actually, lots of people maintain their init file as an Org file. There's some
discussion here:

https://emacs.stackexchange.com/questions/3143/can-i-use-org-mode-to-structure-my-emacs-or-other-el-configuration-file

Another option mentioned there is to use outline-mode, which gives you Org-style
visibility cycling in non-Org files.


-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-09 19:01                   ` Joost Kremers
@ 2020-11-10  0:13                     ` Robert Thorpe
  2020-11-10  0:36                       ` Joost Kremers
  0 siblings, 1 reply; 17+ messages in thread
From: Robert Thorpe @ 2020-11-10  0:13 UTC (permalink / raw)
  To: Joost Kremers; +Cc: help-gnu-emacs

Joost Kremers <joostkremers@fastmail.fm> writes:

> Another option mentioned there is to use outline-mode, which gives you Org-style
> visibility cycling in non-Org files.

I think you mean outline-minor-mode or outshine-mode.

Outline-mode itself only works in an outline-mode buffer, it can't be
used in other sorts of buffer.

BR,
Robert Thorpe



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Multiline Comments
  2020-11-10  0:13                     ` Robert Thorpe
@ 2020-11-10  0:36                       ` Joost Kremers
  0 siblings, 0 replies; 17+ messages in thread
From: Joost Kremers @ 2020-11-10  0:36 UTC (permalink / raw)
  To: help-gnu-emacs


On Tue, Nov 10 2020, Robert Thorpe wrote:
> Joost Kremers <joostkremers@fastmail.fm> writes:
>
>> Another option mentioned there is to use outline-mode, which gives you Org-style
>> visibility cycling in non-Org files.
>
> I think you mean outline-minor-mode or outshine-mode.

You are right, of course.

-- 
Joost Kremers
Life has its moments



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-11-10  0:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-08 20:47 Multiline Comments Christopher Dimech
2020-11-09  9:28 ` Jean Louis
2020-11-09 13:01   ` Michael Heerdegen
2020-11-09 13:18     ` Christopher Dimech
2020-11-09 13:33       ` Joost Kremers
2020-11-09 13:55         ` Christopher Dimech
2020-11-09 14:37           ` Joost Kremers
2020-11-09 15:08             ` Christopher Dimech
2020-11-09 15:23               ` Joost Kremers
2020-11-09 15:35                 ` Christopher Dimech
2020-11-09 19:01                   ` Joost Kremers
2020-11-10  0:13                     ` Robert Thorpe
2020-11-10  0:36                       ` Joost Kremers
2020-11-09 17:51                 ` Christopher Dimech
2020-11-09 10:10 ` Michael Heerdegen
2020-11-09 12:14   ` Christopher Dimech
2020-11-09 13:29     ` Joost Kremers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).