What is the logic behind the weird lisp docstring (left) indentation?
Clash Royale CLAN TAG#URR8PPP
Why is the third line in this code indented "too much" to the left?
It feels "off" to me.
(defun hello-world nil
"Greet the world.
This function implements the canonical example program."
(interactive)
(message "Hello world!"))
doc-strings
add a comment |
Why is the third line in this code indented "too much" to the left?
It feels "off" to me.
(defun hello-world nil
"Greet the world.
This function implements the canonical example program."
(interactive)
(message "Hello world!"))
doc-strings
add a comment |
Why is the third line in this code indented "too much" to the left?
It feels "off" to me.
(defun hello-world nil
"Greet the world.
This function implements the canonical example program."
(interactive)
(message "Hello world!"))
doc-strings
Why is the third line in this code indented "too much" to the left?
It feels "off" to me.
(defun hello-world nil
"Greet the world.
This function implements the canonical example program."
(interactive)
(message "Hello world!"))
doc-strings
doc-strings
edited Jan 25 at 18:15
Lorem Ipsum
1,039413
1,039413
asked Jan 25 at 16:07
american-ninja-warrioramerican-ninja-warrior
980714
980714
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It's so the docstring will look normal when the user views it in the help system.
The first line of the docstring is indented.
Since the G
directly follows the double quote "
there is no indentation in first line of the printed version of the string.
The newline at the end of the first line of the string is part of the string.
If you would add indentation to the second line of the string. That indentation would also be part of the printed representation of the string. That is most likely unwanted.
do you have a screenshot
– american-ninja-warrior
Jan 25 at 16:19
5
Evaluate the lisp code by placing your cursor after the last parenthesis and pressingC-x C-e
. Then check the help withC-h hello-world
and see for yourself. :) Experiment to see what happens when you modify the docstring.
– Lorem Ipsum
Jan 25 at 16:44
OTOH, the help system could strip off spaces at the beginning of lines when displaying docstrings. This would only be a problem if there are docstrings with intentional indentation.
– Barmar
Jan 25 at 20:20
@Barmar it would also be a problem wrt maximum line lengths in the code. There's simply no benefit to expending effort on anything like that. The current approach is the simplest and most sensible approach (and I've never seen anyone get confused by it before).
– phils
Jan 25 at 22:05
And Lisp mode doesn't really provide any easy way to type a string with all the lines indented like that.
– Barmar
Jan 25 at 22:06
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "583"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f47405%2fwhat-is-the-logic-behind-the-weird-lisp-docstring-left-indentation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's so the docstring will look normal when the user views it in the help system.
The first line of the docstring is indented.
Since the G
directly follows the double quote "
there is no indentation in first line of the printed version of the string.
The newline at the end of the first line of the string is part of the string.
If you would add indentation to the second line of the string. That indentation would also be part of the printed representation of the string. That is most likely unwanted.
do you have a screenshot
– american-ninja-warrior
Jan 25 at 16:19
5
Evaluate the lisp code by placing your cursor after the last parenthesis and pressingC-x C-e
. Then check the help withC-h hello-world
and see for yourself. :) Experiment to see what happens when you modify the docstring.
– Lorem Ipsum
Jan 25 at 16:44
OTOH, the help system could strip off spaces at the beginning of lines when displaying docstrings. This would only be a problem if there are docstrings with intentional indentation.
– Barmar
Jan 25 at 20:20
@Barmar it would also be a problem wrt maximum line lengths in the code. There's simply no benefit to expending effort on anything like that. The current approach is the simplest and most sensible approach (and I've never seen anyone get confused by it before).
– phils
Jan 25 at 22:05
And Lisp mode doesn't really provide any easy way to type a string with all the lines indented like that.
– Barmar
Jan 25 at 22:06
add a comment |
It's so the docstring will look normal when the user views it in the help system.
The first line of the docstring is indented.
Since the G
directly follows the double quote "
there is no indentation in first line of the printed version of the string.
The newline at the end of the first line of the string is part of the string.
If you would add indentation to the second line of the string. That indentation would also be part of the printed representation of the string. That is most likely unwanted.
do you have a screenshot
– american-ninja-warrior
Jan 25 at 16:19
5
Evaluate the lisp code by placing your cursor after the last parenthesis and pressingC-x C-e
. Then check the help withC-h hello-world
and see for yourself. :) Experiment to see what happens when you modify the docstring.
– Lorem Ipsum
Jan 25 at 16:44
OTOH, the help system could strip off spaces at the beginning of lines when displaying docstrings. This would only be a problem if there are docstrings with intentional indentation.
– Barmar
Jan 25 at 20:20
@Barmar it would also be a problem wrt maximum line lengths in the code. There's simply no benefit to expending effort on anything like that. The current approach is the simplest and most sensible approach (and I've never seen anyone get confused by it before).
– phils
Jan 25 at 22:05
And Lisp mode doesn't really provide any easy way to type a string with all the lines indented like that.
– Barmar
Jan 25 at 22:06
add a comment |
It's so the docstring will look normal when the user views it in the help system.
The first line of the docstring is indented.
Since the G
directly follows the double quote "
there is no indentation in first line of the printed version of the string.
The newline at the end of the first line of the string is part of the string.
If you would add indentation to the second line of the string. That indentation would also be part of the printed representation of the string. That is most likely unwanted.
It's so the docstring will look normal when the user views it in the help system.
The first line of the docstring is indented.
Since the G
directly follows the double quote "
there is no indentation in first line of the printed version of the string.
The newline at the end of the first line of the string is part of the string.
If you would add indentation to the second line of the string. That indentation would also be part of the printed representation of the string. That is most likely unwanted.
edited Jan 25 at 16:47
Tobias
13.1k1833
13.1k1833
answered Jan 25 at 16:16
Sue D. NymmeSue D. Nymme
901611
901611
do you have a screenshot
– american-ninja-warrior
Jan 25 at 16:19
5
Evaluate the lisp code by placing your cursor after the last parenthesis and pressingC-x C-e
. Then check the help withC-h hello-world
and see for yourself. :) Experiment to see what happens when you modify the docstring.
– Lorem Ipsum
Jan 25 at 16:44
OTOH, the help system could strip off spaces at the beginning of lines when displaying docstrings. This would only be a problem if there are docstrings with intentional indentation.
– Barmar
Jan 25 at 20:20
@Barmar it would also be a problem wrt maximum line lengths in the code. There's simply no benefit to expending effort on anything like that. The current approach is the simplest and most sensible approach (and I've never seen anyone get confused by it before).
– phils
Jan 25 at 22:05
And Lisp mode doesn't really provide any easy way to type a string with all the lines indented like that.
– Barmar
Jan 25 at 22:06
add a comment |
do you have a screenshot
– american-ninja-warrior
Jan 25 at 16:19
5
Evaluate the lisp code by placing your cursor after the last parenthesis and pressingC-x C-e
. Then check the help withC-h hello-world
and see for yourself. :) Experiment to see what happens when you modify the docstring.
– Lorem Ipsum
Jan 25 at 16:44
OTOH, the help system could strip off spaces at the beginning of lines when displaying docstrings. This would only be a problem if there are docstrings with intentional indentation.
– Barmar
Jan 25 at 20:20
@Barmar it would also be a problem wrt maximum line lengths in the code. There's simply no benefit to expending effort on anything like that. The current approach is the simplest and most sensible approach (and I've never seen anyone get confused by it before).
– phils
Jan 25 at 22:05
And Lisp mode doesn't really provide any easy way to type a string with all the lines indented like that.
– Barmar
Jan 25 at 22:06
do you have a screenshot
– american-ninja-warrior
Jan 25 at 16:19
do you have a screenshot
– american-ninja-warrior
Jan 25 at 16:19
5
5
Evaluate the lisp code by placing your cursor after the last parenthesis and pressing
C-x C-e
. Then check the help with C-h hello-world
and see for yourself. :) Experiment to see what happens when you modify the docstring.– Lorem Ipsum
Jan 25 at 16:44
Evaluate the lisp code by placing your cursor after the last parenthesis and pressing
C-x C-e
. Then check the help with C-h hello-world
and see for yourself. :) Experiment to see what happens when you modify the docstring.– Lorem Ipsum
Jan 25 at 16:44
OTOH, the help system could strip off spaces at the beginning of lines when displaying docstrings. This would only be a problem if there are docstrings with intentional indentation.
– Barmar
Jan 25 at 20:20
OTOH, the help system could strip off spaces at the beginning of lines when displaying docstrings. This would only be a problem if there are docstrings with intentional indentation.
– Barmar
Jan 25 at 20:20
@Barmar it would also be a problem wrt maximum line lengths in the code. There's simply no benefit to expending effort on anything like that. The current approach is the simplest and most sensible approach (and I've never seen anyone get confused by it before).
– phils
Jan 25 at 22:05
@Barmar it would also be a problem wrt maximum line lengths in the code. There's simply no benefit to expending effort on anything like that. The current approach is the simplest and most sensible approach (and I've never seen anyone get confused by it before).
– phils
Jan 25 at 22:05
And Lisp mode doesn't really provide any easy way to type a string with all the lines indented like that.
– Barmar
Jan 25 at 22:06
And Lisp mode doesn't really provide any easy way to type a string with all the lines indented like that.
– Barmar
Jan 25 at 22:06
add a comment |
Thanks for contributing an answer to Emacs Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f47405%2fwhat-is-the-logic-behind-the-weird-lisp-docstring-left-indentation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown