What is the logic behind the weird lisp docstring (left) indentation?












3















Why is the third line in this code indented "too much" to the left?
It feels "off" to me.



enter image description here



(defun hello-world nil
"Greet the world.
This function implements the canonical example program."
(interactive)
(message "Hello world!"))









share|improve this question





























    3















    Why is the third line in this code indented "too much" to the left?
    It feels "off" to me.



    enter image description here



    (defun hello-world nil
    "Greet the world.
    This function implements the canonical example program."
    (interactive)
    (message "Hello world!"))









    share|improve this question



























      3












      3








      3








      Why is the third line in this code indented "too much" to the left?
      It feels "off" to me.



      enter image description here



      (defun hello-world nil
      "Greet the world.
      This function implements the canonical example program."
      (interactive)
      (message "Hello world!"))









      share|improve this question
















      Why is the third line in this code indented "too much" to the left?
      It feels "off" to me.



      enter image description here



      (defun hello-world nil
      "Greet the world.
      This function implements the canonical example program."
      (interactive)
      (message "Hello world!"))






      doc-strings






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 25 at 18:15









      Lorem Ipsum

      857212




      857212










      asked Jan 25 at 16:07









      american-ninja-warrioramerican-ninja-warrior

      958714




      958714






















          1 Answer
          1






          active

          oldest

          votes


















          8














          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.






          share|improve this answer


























          • 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 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











          • @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











          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          8














          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.






          share|improve this answer


























          • 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 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











          • @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
















          8














          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.






          share|improve this answer


























          • 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 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











          • @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














          8












          8








          8







          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.






          share|improve this answer















          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 25 at 16:47









          Tobias

          13k1833




          13k1833










          answered Jan 25 at 16:16









          Sue D. NymmeSue D. Nymme

          846511




          846511













          • 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 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











          • @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








          • 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













          • 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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?