How to re-align column of text table in emacs? - emacs

When I insert a table using M-x table-insert
I get the following table:
+-----+-----+-----+
| | | |
+-----+-----+-----+
| | | |
+-----+-----+-----+
| | | |
+-----+-----+-----+
But When I add content the | become disaligned like this
+-----+-----+-----+
| content | | |
+-----+-----+-----+
| | | |
+-----+-----+-----+
| | | |
+-----+-----+-----+
How do you realign the column?
When I press enter it just creates that:
+-----+-----+-----+
| contecnt | | |
| | | |
+-----+-----+-----+
| | | |
+-----+-----+-----+
| | | |
+-----+-----+-----+

You enter the corresponding cell and start editing the text with C-c' it opens the edit mode and automatically wraps the text accordingly. Once done type C-c' again and you're back in the nicely formated table.

The table should expand as needed for words longer than the width of the column, and the entire column should widen when this happens. Multiple words will wrap appropriately when the width is reached if there is space to break the line. Remember to use tab to move from cell to cell in the table.
Column width can be changed manually with M-x table-widen-cell and M-x table-narrow-cell.
Sometimes Emacs gets confused for some reason, and something like what you describe happens. One way to fix it is to exit table mode with M-x table-unrecognize-table, manually edit the table, then do M-x table-recognize-table. It's not ideal, but sometimes is easiest.

Yes, org-mode table and table-mode table functionality are interfering with one another and preventing the table from realigning properly. I'm not sure how to fix that, but you mentioned in a comment that you are using table-mode specifically because you want multi-lined cells in the table.
I suggest that instead you use an org table (with M-x org-table-create) and then you can split long lines over multiple lines within the same cell by calling M-x org-table-wrap-region at the point where you want the split.

Just press TAB within the table and it will autoalign.

Related

How to select a column of a table in emacs org mode

I can't find my way around copying a column, or a series of them, from a table.
The only solution I found so far is to copy the whole table and then delete the columns I don't need.
I suppose there must be another easier way for this. Maybe I am just too tired to realize how to do it.
I think the easiest way would be to take advantage of emacs rectangles
To create your rectangle, put your cursor at one of the corners of the rectangle you want to create.
Use C-SPC, or whatever you have set-mark-command set to.
Place your cursor at the diagonal corner of your rectangle.
Use C-x r rr to copy the rectangle to the register named r
Use C-x r ir to insert the rectangle that is being held in the register named r.
Following this process will copy and insert the columns that you want. You may need to repeat this process if the columns are not adjacent.
NOTE
I am using a bolded r to denote that this is technically a name of the register, and not some special input.
If you specifically want to copy the column(s) into another org table (or indeed back into the original table), there's support for that.
See C-hf org-table-copy-region RET
It works much like the regular rectangle commands, so it's not a better interface for selecting the column; but the associated paste command is smart about what it does with the content.
I you are planning to use emacs rectangle command you avoid the use of registers by using the command copy-rectangle-as-kill bound C-xrM-w, execute the command after selecting a region this will copy the rectangle (see this for an example of how marking rectangles works). Then you can paste the copied retangle by doing C-xry.
UPDATE
The page org-mode hacks describes a way to copy columns using org-table formulas. You will need to name the table.
Here is an example of using table formulas to copy columns from another table
Suppose you have following table named FOO, it is necessary to name the table for referring it from table formulas.
#+TBLNAME: FOO
| 0 | 2 | 1 |
| 1 | 3 | 2 |
| 2 | 4 | 3 |
You want to copy the columns 1 and 3 from table FOO to column 1 and 3 of the following table (lets call it B)
| | 5 | |
| | 6 | |
| | 7 | |
The following formula will do the trick, you will need to copy the formula below the table B and move cursor on the formula and do C-cC-c
#+TBLFM: $1=remote(FOO,###$1)::$2=remote(FOO,###$3)
The table B will be converted to the following
| 0 | 5 | 1 |
| 1 | 6 | 2 |
| 2 | 7 | 3 |
You can read about the syntax of the org table formulas here, basically $N refers to Nth column, #N refers to Nth row. ## and $# can be used instead of N to refer the row and column where the current value goes. remote(table-name, #N$N) refers to the Nth row and Nth column of the table table-name. :: concats multiple formulas.
I too had trouble using the standard rectangle operations. When moving to the next column, all of all of the rows between the point and the mark were highlighted. When I tried copying columns by formula as described above and in the org mode hacks, org threw errors if the column's values were non-numeric with more than one word.
But a good hint about cutting and pasting revealed that the problem is the initial direction of motion of the cursor. Moving first rightward to the next column, then down highlights the correct region. Standard rectangle operations then work correctly.
The "native" way in org mode is already covered in the answer by user2053036; I just wanted to add that in the simpler context, "to copy a column within a table": Let's say you have this table
| hello | world |
| is | good |
And want to repeat column 2 in column 3.
Steps:
Place the cursor after the bottom right | of the table
Open a new column to the right using keys Alt-Shift-<right>
| hello | world | |
| is | good | |
Add the "row copy from" formula (for example by putting cursor to row 1 column 3 and typing =$1 C-c C-c; or just type the TBLFM below the table and jump to step 4)
| hello | world | hello |
| is | good | |
#+TBLFM: $3=$1
Place the cursor on the TBLFM and type C-c C-c
| hello | world | hello |
| is | good | is |
#+TBLFM: $3=$1
That will copy column 1 to column 3.

Doxygen Table drawing

I would like to insert a ASCII art table (as below) in the documentation.
The Markdown feature of doxygen comes in the way and messes it all up.
I've tried to the HTML table and they are fine but the source document becomes unreadable then.
Can I somehow get doxygen not to process a section but still include it in the output file?
Similar to here where 4 blanks allow to to inserted already formatted text in fixed width font.
|-------------|-------------------------|---------------|
|AUTO_NEW_OFF | Entry action | LED_FLASH |
| | | SEQ_OFF |
|-------------|-------------------------|---------------|
| | eXit action | |
|-------------|-------------------------|---------------|
| | | |
|-------------|-------------------------|---------------|
| OFF | SEQ complete | |
|-------------|-------------------------|---------------|
I think I can answer this myself already.
The Fenced Code Blocks ( 3 x ~) feature seems to work ok
~~~
|-------------|-------------------------|---------------|
| MAN_NEW_OFF | Entry action | LED_FLASH |
| | | SEQ_OFF |
|-------------|-------------------------|---------------|
~~~
An improvement on fenced code would be to surround the table with the doxygen commands #verbatim and #endverbatim.
If you use a "code" style, be that markdown's ~~~ or doxygen's #code, there's a chance that current or future versions of Doxygen will start trying to colour it in syntactically.

Making applications for different monitor sizes

I have been developing an application with the following layout (greatly simplified):
+----------------------------------+
| +----------------+ |
| Main | | Info |
| | Interactive | |
| Actions | | And |
| | Graph | |
| Go | | Forms |
| | (Resizable) | |
| Here | | |
| +----------------+ |
+----------------------------------+
With a screen resolution of 1440x900. There are some minimum widths set for buttons etc to make them more beautiful (so for example the label inside has some distance from the button borders). Now if I resize the window to about 800x600, it becomes like this:
+----------------------+
| +----+ |
| Main | | Info |
| Actions | | And |
| | | |
| Go | | Forms |
| Here | | |
| +----+ |
+----------------------+
Which is not so beautiful. The reason the middle panel gets so small is that the labels on either sides cannot be shrunk.
The question is, how can I tell gtk to scale everything (e.g. images, fonts etc) inside a window?
If such a functionality doesn't exist, what choice do I have for making everything inside the window (or at least the font sizes) smaller or bigger, without having to manually change every widget?
Gtk doesn't allow you to "scale" anything automatically in a window. It would also be a bad idea, as you don't know how little the window will be (not only because of the screen resolution, but because of the user manually resizing the window).
I'd suggest you to redesign your layout. It's complicated to suggest a solution without a real screenshot, but maybe the Main Actions could be replaced in the top part of the window.
Use a toolbar with your main actions, and put other actions in a menu bar. This will give more space to the interactive graph. Info and forms, if not required at every moment, may be in a tabbed view, or in a popup. Hard to tell more without a screenshot.

How to use Emacs auto-complete/snippets?

I've been using the emacs-live and it is amazing!
I just can't figure out how to use the autocomplete/snippets, the suggestions pop up, you can cycle through the options, but how do you select an option.
I've tried numinous things to get it to apply the selection, nothing seems to work, it's driving me crazy.
Can someone please help me?
I seem to have fixed the problem by pulling the latest version of the config. Not sure what I changed or was changed but it is working now.
Digging around I found a manual for the plugin with this:
### Summary ###
Completion will be started by inserting characters. After completion is started,
operations in the following table will be enabled temporarily. After completion
is finished, these operations will be disabled.
| Key | Command | Description |
|-----------|-------------|---------------------------|
| TAB, C-i | ac-expand | Completion by TAB |
| RET, C-m | ac-complete | Completion by RET |
| down, M-n | ac-next | Select next candidate |
| up, M-p | ac-previous | Select previous candidate |
| C-?, f1 | ac-help | Show buffer help |
To stop completion, simply use `C-g`.

In MS Word, how do you create a list in table that separate bullet and content?

So I have this table with 2 columns and I want to put a list in it such that
+-------------------------------+
| * | Content 1 |
| * | Content 2 |
| * | Content 3 |
| * | Content 4 |
| * | Content 5 |
+-------------------------------+
the bullet is in the left cell, and the content is on the right cell, is this possible? I am using MS Word 2010.
You create a two-column table, set column widths to automatically adjusted (or something else, as you like) and you enter the bullet character “•” in the cells of the first column, e.g. by typing Alt+0149. I don’t think there’s a way to generate the bullets automatically in the same sense as you can control the bullets in a bulleted list.